Chapter 3. PROGRAMMING BY INTENTION
'Tis but thy name that is my enemy;
...
O, be some other name!
Romeo and Juliet, Act 2 Scene 2 William Shakespeare
This chapter discusses programming by intention, a central idea in XP. It means making your intent clear when you write code.
Have you ever had to work on a piece of code and found that it was hard to understand? Maybe the logic was convoluted, the identifiers meaningless, or worse, misleading. You say there was documentation? Was it readable? Did it make sense? Was it up to date with the code? Are you sure? How do you know?
The main idea of programming by intention is communication, specifically, the communication of our intent to whomever may be reading the code. The goal is to enable them to understand what we had in mind when we wrote the code.
Let's look at what we need to do in order to have our code be as understandable and intent-revealing as possible.
|
No comments:
Post a Comment