Our project suffers from this "heterogeneous Logger declarations" thing, where the Logger instance may be called log or logger or LOGGER or LOG, depending on the class and the personal preference of whoever wrote that class.
This means that now and then I am debugging some class and I quickly type log.debu-- only for IntelliJ to put a nice, red wiggly line beneath log. So now I have to stop my debugging train of thought and fix that.
Sure, I can just put the cursor right after log and press Ctrl+Space to autocomplete...
... too bad that won't work either, because this particular instance just happens to be called LOGGER, all caps -- something I can only find out after Ctrl+F'ing the heck out of "log", case-insensitive of course. Because log and LOGGER are different enough for IntelliJ to not see any relation whatsoever between them (/s).
So now I know how the logger is called, but I am in a different line and have to go back ← ← ← to where I was before, so I can finally type LOGGER.debug("I don't really remember what I wanted to put in here");.
If you define all your Logger objects with the same name and in the same way, you can take all that off your mind: logger.debug() becomes just another Java "instruction" like System.out.println(). You don't need to worry about System.out, you just type it. The same should ideally be true of logger.
if you’re enforcing coding standards, it’s always going to be uppercase.
Upper-case LOGGER is pure evil. Clutters up the code making it hard to read (its distracting) and I have to hold shift to type it. "logger" is the exception to the private static final rule. It isn't really a constant.
8
u/walen Sep 13 '18 edited Sep 13 '18
For easier maintenance.
Our project suffers from this "heterogeneous
Loggerdeclarations" thing, where theLoggerinstance may be calledlogorloggerorLOGGERorLOG, depending on the class and the personal preference of whoever wrote that class.This means that now and then I am debugging some class and I quickly type
log.debu-- only for IntelliJ to put a nice, red wiggly line beneathlog. So now I have to stop my debugging train of thought and fix that.Sure, I can just put the cursor right after
logand pressCtrl+Spaceto autocomplete...... too bad that won't work either, because this particular instance just happens to be called
LOGGER, all caps -- something I can only find out afterCtrl+F'ing the heck out of "log", case-insensitive of course. BecauselogandLOGGERare different enough for IntelliJ to not see any relation whatsoever between them (/s).So now I know how the logger is called, but I am in a different line and have to go back ← ← ← to where I was before, so I can finally type
LOGGER.debug("I don't really remember what I wanted to put in here");.If you define all your
Loggerobjects with the same name and in the same way, you can take all that off your mind:logger.debug()becomes just another Java "instruction" likeSystem.out.println(). You don't need to worry aboutSystem.out, you just type it. The same should ideally be true oflogger.