I was wondering what people thought about logging. The Monkhouse & Camerlengo book includes it. On the other hand, it clutters the code and decreases readability. It isn't a requirement, and is a place to lose points it you make a silly mistake (like inconsistent names or misconfigure a class and sending a bunch of logging output to the standard output/error). So do people think it is a good idea on balance?
John [ December 27, 2007: Message edited by: John Donoghue ]
SCJP 5<br />SCBCD 1.3<br />SCJD<br />SCWCD 1.4, 5<br />SCBCD 5 -- working on it
Originally posted by John Donoghue: On the other hand, it clutters the code and decreases readability.
Hmmm - maybe. The same argument could be used against including comments. I personally find that a well placed log message will work instead of a comment when I am reading the code, and simultaneously give me good debugging information when I am trying to look at a run that has a problem.
Originally posted by John Donoghue: It isn't a requirement,
Very true, and we do argue several times throughout the book that going beyond the requirements can be against your best interests (and there is even a comment to that effect in your instructions). I personally feel that this is one area where a little step outside the minimum requirements is actually a good thing, and shows a little more professionalism.
Originally posted by John Donoghue: ...and is a place to lose points it you make a silly mistake
Originally posted by John Donoghue: ...(like inconsistent names ...
Perhaps - I think this sort of problem could happen even just as easily with comments in the code, so I don't see it as a particular problem.
Originally posted by John Donoghue: or misconfigure a class and sending a bunch of logging output to the standard output/error).
I think this is possibly a reason for the logging - these sorts of errors will then be apparent when you run the application, rather than when the assessor steps through your code.
Thanks for taking the time to respond. I have been waffling about this for a while, but in the past week I've hit a couple of places where the having the logging code would help, so I believe that you are correct.
BTW: I love the book. Thanks to you and Terry for writing it. [ January 01, 2008: Message edited by: John Donoghue ]