Sunday, October 21, 2007

Pain and Pleasure

Do you ever wonder how much a programmer's personality contributes to writing good code? I noticed that the more pain a programmer can tolerate, the worse his code is.

For example, some people can tolerate Java code like this:

getHibernateTemplate().execute(new HibernateCallback() {
  public Object doInHibernate(Session session) {
    Customer customer = new Customer("Eitan");
    customer.setAccountNo(12345);
    session.save(customer);
  }
}

Others would shudder at the sight of extra brackets and noisy use of the callback, and thus push the callback into the framework or a super class to get something like this:

Customer customer = new Customer("Eitan");
customer.setAccountNo(12345);
session.save(customer);

I also noticed that the more sensitive a programmer is to pain, the more sensitive he can be to pleasure too. Sensitive programmers tend to paint beautiful pictures in code because they can better sense beauty in certain patterns of writing code.

What does sensitivity boil down to though? Can a programmer develop his sensitivity further? Well, I believe that sensitivity stems from awareness and focus on how maintainable and readable code is. The more attention a programmer gives to these aspects, the more he will feel pain in badly written code and pleasure and very easy to read code.

In other words, keep code readability and maintainability at the back of your mind, and you will be able to develop your sensitivity further.

1 comment:

Victoria Wang said...

I like that. Well said!