I'd suggest going with some combination of the 2nd and 3rd ideas:
- Put the labels in a flat text file and read them into an array when I need to do the translation. This will mean I will need separate text files for each device type (15 to 20).
- Stick these structures into a separate module and use an access method to pull the info out as needed.
I would probably keep the data in separate files so it was easier to maintain. 15-20 files isn't that bad. I'd also favor a flat text format rather than a database or persisted data structure format (like Storable), since they would be human-readable and could be easily read (with minimal dependencies) by any other applications that needed the data.
Writing accessors for each file/device could certainly streamline the interface. You could even create a (single) class that loaded the correct data as objects are instantiated (like a simplified factory design, if my OO terminology is correct). If the data really is as simple as you describe, though, objects may be overkill. Simply returning an arrayref may be just as easy.
More experienced monks will likely suggest better ways to do this. :-)
In reply to Re: Best Practice for Lots of Static Data
by bobf
in thread Best Practice for Lots of Static Data
by SirBones
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |