Wednesday, August 15, 2007

Discipline

Another must-read post by Jeff Atwood on how Discipline Makes Strong Developers. I couldn't agree more. Only discipline on the part of the developers makes code that is concise and easy to maintain. Having an eye for detail is one of the core skills of every developer.

Currently I'm reading the book Inside Windows Communication Foundation by Justin Smith. One of the code examples in his book contains the following piece of code:

// commented out for clarity // Console.WriteLine("{0}\n", message.ToString());

I'm sorry, but this doesn't clarify anything. On the contrary, I actually found the code sample in question more difficult to read.

At some point in our careers as a developer, we inherit some piece of legacy code. I don't know about you, but I already had my share of legacy code that was sprinkled with lines of code that were commented out for some reason. This proved to me that the last developer who worked on this code-base was simply undisciplined and didn't care about what he was doing. He didn't bother to cleanup his mess after he stopped working on the project. Some would argue that it shows the history of the code that went into production. We have source-control systems for that, people! When I see these kinds of code, the lyrics of It's Time For Violence just cross my mind. 

Again, good code should read like a good book. Good code should invite others to read it. Good code is all about the details. Writing good code that is easy to maintain takes lots and lots of discipline.

No comments: