I've noticed some projects like to store constants in their own file, i.e constants used globally and in the main program loop might clutter the main file so perhaps they look to place them elsewhere and then reference/import file/class.
I understand that when writing an OOP class that you'd want to keep all constants at the header of the class file so they can be referenced statically as such:
myCar.setColour(Colour.RED);
Where RED
is a colour constant in the Colour
class.
What is good practice for having a large amount of constants, should they just be at the top of your main file or is it in any way wise to have maybe a ProgramConstants
class that is purely static, public and available to read?