Archive for the ‘comment’ Category

Why comments are evil…

without comments

We’ve heard a lot of times that comments are considered as an evil. And yet we always found a way to say, ‘but in particular case, comments can be very useful’.

Should we use comments at all?
Of course!!!!!!! My mistake was to name the commandment “Comments are evil”, is just a guideline, as any other principle you apply in software development, sometimes we just produce crappy code, for many reasons, we are under pressure, we don’t know the technology we are working with… Then for the love of god, use comments!! There are other times where we have prodcuded good code wich has a few comments, that’s fine, we cannot always look for the perfection. What “comments are evil” really means is that you should always push yourself to use as few comments as possible, not because you are lazy, but because they are not necessary.

And yet I find it’s hard to take when I explored the code of Eclipse:

package org.eclipse.jface.preference;


 * A special abstract preference page to host field editors.
 * <p>
 * Subclasses must implement the <code>createFieldEditors</code> method
 * and should override <code>createLayout</code> if a special layout of the field
 * editors is needed.
 * </p>
public abstract class FieldEditorPreferencePage extends PreferencePage
        implements IPropertyChangeListener {

Particularly this sentence: and should override createLayout if a special layout of the field editors is needed.

WHY? Because there is no createLayout in the class, not even in the parent class, not in the interface, not anywhere.

So, let’s just code a better code, won’t you?

PS: Just in case anyone curious, the Eclipse version is 3.5.2.
PS 2: Don’t comment this blog post! :P

Related posts:

  1. Don’t be evil
  2. What are the important improvements on Eclipse Galileo 3.5 (for me)
  3. Eclipse plugin: Introduce Static Imports

Why comments are evil… originally appeared on satukubik on April 22, 2010.

Written by Nanda Firdausi

April 22nd, 2010 at 2:13 pm