Annoying Patterns: Saying what you’re about to do

April 18, 2007 on 5:47 pm | In Annoying Patterns |

This pattern is best demonstrated with a few examples:


// Get a connection
Connection connection = ConnectionFactory.getConnection();
 

// Send the message
connection.send();
 

// Start all the servers
for (Server server : serverList) {
    server.start();
}
 

Basically, the comment is describing what you are doing on the next line, and is just not needed.
Sometimes the comments are telling you something, for example:


// Send the message to everyone
connection.send();
 

Could perhaps be telling you that a method needs to be renamed:


connection.sendTheMessageToEveryone();
 

Then the comment can be removed and it is clear what the code is doing.

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Powered by Cheese.     RSS Entries Feed.     RSS Comments Feed     ^Top^