For magic numbers where the number actual has a meaning and is not just a label you obviously should not use enums. Then the old style is still the best.
public static final int PAGE_SIZE = 300;
When you are just labelling something you would use an enum.
enum Drink_Size
{
TALL,
GRANDE,
VENTI;
}
Sometimes it makes sense to put all your global constants in their own class, but I prefer to put them in the class that they are most closely tied to. That is not always easy to determine, but at the end of the day the most important thing is that your code works :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…