When I make any sort of program that references non-code files, such as images or textual data saved with the code, I use enumerations whenever possible to force a 1-to-1 relationship between files and constants. This has a number of advantages:
- Finding data your program declares, but does not use, is easier with tools that scan your code.
- Finding data your program uses, but does not declare, will stop your code from compiling!
- If you group your resources, using one enumeration per group prevents accidental cross-pollination, such as referencing an image intended for the user interface in the part of your code that displays charts.
- Your resource loaders need to require an enumeration member to load a resource; without this, none of the above benefits will be realized.
- Finally, if you ever scan your code for quality issues, having this system in place guarantees that an unused enum constant means the corresponding data file is also unused, making maintenance easier.
This applies to ANY type of program. I happen to use it for games in Java, but it works just as well in other types of programs written in other languages with enumerations.