One of the qualities that distinguishes code-and-fix hacking from software craftsmanship is a different idea of what "done" means. If you are hacking 1, the primary goal is to create something that seems to work. If you are a craftsman and you want to create something that may endure, something you can be proud of, that is only part of the story. The XP Simplicity Rules express the difference very well. According to these rules, simple code:
Runs all the testsIn other words, it works. More than that, it demonstrably works because there are tests and they pass. This is a higher bar than just "working". Expresses every idea that we need to expressThis encompasses many aspects of good coding hygiene: The architecture is suited to the job it does. Classes have clear responsibilities. Methods and varibles are named appropriately. Comments explain the tricky parts. BTW a good rule about comments is this: Whenever you think you need a comment to explain something, consider putting the code that would follow the comment into a subroutine with a good name. That way the comment may not be needed and the code will read more clearly. Says everything Once and Only OnceI have written about this in this essay - Don't Repeat Yourself - I won't repeat myself here :-). Has no superfluous partsTake out the cruft! If it's not needed to fulfill the current requirements, get rid of it! Don't worry about keeping stuff you might need later, you can always dig it out of source-code control and put it back in. Comment it out for a while if you must, but after a while rip out the comments. "Perfection, then, is finally achieved, not when there is nothing left to add, but when there is nothing left to take away. " --Antoine de Saint Exupéry
last change 2004-04-30 23:14:08 |
What does it mean to do The Simplest Thing that could Possible Work? BlogRoll |
© 2004, Kent Johnson