Friday, May 20, 2005

Coding principles

* Avoid duplicate code. Anywhere there is duplicate code there is the potential for bugs. Code must always be changed, and anytime you leave the same code in two places, you run the risk of changing it in once place and not in the other, thus introducing a bug. This is the value of Simplicity.

* Don't go too long without soliciting input. You need to get input from users, to make sure that the application is doing the right things. You need to get input from programmers, to make sure your design and architecture doesn't overlook flaws. These are the values of Communication and Feedback.

* Make changes when changes need to be made. Don't fall into the trap of avoiding making changes because "it might break something somewhere." Ideally, of course, you have enough unit tests running to verify that things don't break when you change code, or at least that if they do, you know it quickly. But once the code is so complicated you are afraid to make changes, you can't respond to customer input quickly enough to keep up with your competition. This is the value of Courage.

It's interesting that these principles feed off each other. If your code has Simplicity, you are more likely to have Courage to change, which allows you to respond to Feedback more quickly.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.