Wednesday, October 24, 2007

Less code or what?

My philosophy of coding is less code is always better*. That is, less code needs less effort to maintain and in case of bugs you need to examine less code to spot where a bug lives. This is important when a legacy code is being maintained. It is usually acceptable to disable a legacy code to implement a new feature or fix an existing bug. During this process, some code usually becomes redundant and it should be thrown away. However, this is scary. I haven't seen a lot of developers that feel comfortable by deleting other people's code. I understand this to some extent. On the other hand, leaving a redundant code in place is scary too. Redundant codes confuse developers. Experienced developers usually come to this question of why the hell this code is there and they usually spend days to find out well sloth is a real sin. This is when people should throw code away. Throw your redundant code away, and by code I mean any form of code, either Java code or SQL statement.

 

 

 

 

* This excludes crazy untraceable codes that break code usage searches and, therefore, prevent refactoring tools from functioning. One example is Java Reflection API which may save few (hundred) lines of code but it lets your code live as shadows.

No comments: