A couple weeks ago, I had a chance to talk to one of my old friends who had been running his startup firm for about 2 years. He came to Bangkok for his business and stayed at my place. We talked about a lot of things especially about how his business was going. He had shared with me his story regarding how hard it was to find and hire a decent developer.  We both agreed that there were not many developers here in Thailand (compare to the number of all university graduates) that had passion in developing software.  My friend told me that when he took a look at the code written by his staff, there were many times that he felt like he could make it a lot better by just adding some simple little changes here and there.

Well, this kind of talk isn’t new. The question has been asking for long time. What is the most important virtue for a man to be successful in his professional life?  Is it the level of intelligence or the passion or the hard working? In forum, soon-to-be-graduates keep asking what are the abilities or skill that the potential employers have been looking for. Novice developers take two or three training courses to acquire knowledge about the coolest technology. There is nothing wrong about doing that. In fact, it’s quite a reasonable preparation for jobs applying.  But sometime I think that it’s not so much about having the most advance skill. In the entry level, it’s more like having great attitude and strong passion.

If you love what you are doing (I know it’s hard), there is great chance that you will spend more time or investing more effort in your work. You are doing that not because you are hoping to get promotion to the next level as soon as possible but because you care about your work itself. A module of your code may already wok just fine. But if you keep learning, one day you may find out that with just some little changes you can make a lot improvement for the module. Those changes are not so complicate that you may need higher education to figure them out. It may be just a pattern or best practice that you learned from a blog entry you has read this morning.

For example, I have seen many place that Log4J logger has been used as;

public ItemResponse processItem(ItemRequest req) throws ItemException {
String rev;
try {
rev = itemArchive.getRevision(req.getItemID() );
} catch (ItemArchiveException ex) {
logger.error(ex);
//recovery code goes here
}
//some code here
}

If you have spent even little time playing with Log4J you may already know that the above logging will not print the stack trace of  the ItemArchiveException. This can cause a headache in trouble shooting problem in real production. Let’s look at the API doc.

The second line is the version that should be used for logging exception. All the stack trace will be logged.

  • public void error(java.lang.Object message)
  • public void error(java.lang.Object message, java.lang.Throwable t)

With a little change to use logger.error(“Failed to get item revision”, ex) can result in a big benefit here.

Speaking of logging stack trace, in my experience, chained exception is very useful when it comes to investigating log file. You should always includes the cause exception in the exception you are about to throw unless you can make the about-to-be-threw exception so meaningful in itself (which I will say it’s pretty hard to do so).

Let’s look at the above list again. What if I want to throw ItemException if I couldn’t get revision value for the item?

try{
// some code here
} catch (ItemArchiveException ex) {
throw new ItemException("Couldn’t get revision for " +  req.getItemID());
}

It will be quite impossible to know what exactly went wrong by just knowing the ID of the item in trouble. Again, a little change can be really helpful

throw new ItemException(”Couldn’t get revision for ” + req.getItemID(), ex);

I have to tell you that I am not trying to exaggerate the problem of these two cases above. I have experienced both cases in real production code and it cause quite a headache for me.

Now back to my main idea of this post.
Well, I just realized that I don’t have a main idea for this post at all. It’s my rambling about how hard it is to spot developers who really enjoy writing software.