Comments, the more the better… right? Well I thought so too, in fact this is some of my code of a few days ago:
// handle the initialization of jobs
if (request.getParameter("initiateJobs") != null && request.getParameter("initiateJobs").equalsIgnoreCase("true")) {
initializeJobs();
}
// get the trigger info, which will be displayed on the jsp page
List triggerInfo = getTriggerInfo();
request.setAttribute("triggerInfo", triggerInfo);
But what does it really add? Besides two lines of text. The code in the ‘if’ statement should be clear enough for a web programmer, and the method ‘initializeJobs’ tells as much as the comment. Same goes for the two lines of code below that. What would my intention be by putting ‘triggerInfo’ on the request scope? Point made.
Maybe you say ‘it’s faster to read’. Well… I don’t think it is.
if (request.getParameter("initiateJobs") != null && request.getParameter("initiateJobs").equalsIgnoreCase("true")) {
initializeJobs();
}
List triggerInfo = getTriggerInfo();
request.setAttribute("triggerInfo", triggerInfo);
Looking at one of my last lines of code I realized Sammy Larbi and Jeff Atwood have a point.
If your code is as useless and redundant as your comments it must be a nightmare to read.
The usefullness of the code is hard to see without the context of the application, if you think it’s a nightmare to read then I’m glad you’re maintaining someone else’s code
What this post tried to get across is that (some) comments are redundant. Too bad you missed the point of the post.