10 Never be afraid to add code

 

This chapter covers

  • Recognizing symptoms of fear of adding code
  • Overcoming fear of adding code
  • Understanding the trade-offs of code duplication
  • Committing to backward compatibility
  • Lowering risk by using feature toggles

Having discussed the maladies of code in the previous chapter, it is easy to get scared of writing it. After all, the conclusion to chapter 9 was that code adds cost. When talking about code, another source of fear is not writing perfect code. Considering how many ways code can be flawed, perfection is an utterly unrealistic goal. Many considerations play into “perfection”: performance, structure, level of abstraction, ease of use, ease of maintenance, novelty, creativity, correctness, security, and so on. Trying to keep all this in our heads while also trying to solve a nontrivial problem is impossible.

I started coding before I got a formal education in computer science. Back then, I was very productive and creative because my only consideration was making the code work. Then I started university and learned about all the ways code can fail or be bad. My productivity plummeted. I would be given a task and begin by contemplating it for hours or days before writing the first line of code. Once I realized how much effect this coding stage fright was having on me, I started combating it—and I have been fighting it ever since, both in myself and in others.

10.1 Accepting uncertainty: Enter the danger

10.2 Using spikes to overcome the fear of building the wrong thing

10.3 Overcoming the fear of waste or risk with a fixed ratio

10.4 Overcoming the fear of imperfection by embracing gradual improvement

10.5 How copy and paste effects change velocity

10.6 Modification by addition through extensibility

10.7 Modification by addition enables backward compatibility

10.8 Modification by addition through feature toggles

10.9 Modification by addition through branch by abstraction

Summary