java naming conventions say that constants should be in upper case.
In our company I saw declaration of log4j:
So I was wondering why it's not 'LOG'. After some search there were two groups of people, one that uses 'LOG' and the other one that uese 'log'.
The argument for using 'log' was that the logger is not immutable, therefore is not a constant.
So ... should it be log or LOG?
Its just a convention, you can pick what you like. That said, I don't consider the logger to be a constant. For me, a constant is a numeric or String "magic value". Something like
final int MAX_SIZE = 10;
final String ERR_MESSAGE = "Programmer is a bozo";
your log example is just a static variable, its not a magic value.
Also, I do not use the name "log" for all of my loggers, it can be confusing when you subclass the file a few levels deep. So if my class is BigCoolThing,
i tend to name the static log variable bctLog
Joined: Mar 05, 2008
Personally I prefer "log" there. But the basic problem is that it's ambiguous - the naming convention is for "constants", but it's never really defined exactly what that means. Does it refer only to compile-time constants (which are well-defined)? Maybe. Maybe not. Enums? Final references to immutable types? Final references to mutable types? There really is no standard. Almost everyone who follows this convention will use it for compile-time constants and enums at least, but for anything else, it's a matter of opinion with no well-defined answer.
just to add I always think its a good idea to pick and follow a naming convention within a group. It might not always be 'right' but as long as everyone in the group follows it its all good! Mixing up naming convention within a group even if its for the sake of correcting a wrong convention isn't generally a good idea!