No more comments in your code

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.

Tags: ,

Leave a Reply

Enter the word:

My great (?) anti spam system