1 Code quality

 

This chapter covers

  • The reason code quality matters
  • The four goals that high-quality code aims to achieve
  • The six high-level strategies we can use to ensure code is of a high-quality
  • How writing high-quality code actually saves time and effort in the medium to long term

You’ve probably used hundreds, maybe even thousands of different pieces of software in the past year. Every program installed on your computer, every app on your phone, and every self-service checkout you’ve had the pleasure of contending with—we interact with software a lot.

There are also many pieces of software that we depend on without even necessarily realizing it. We trust our bank, for example, to have a well-behaved backend system that isn’t going to unexpectedly transfer the contents of our bank account to someone else, or suddenly decide that we’re in millions of dollars of debt.

Sometimes we encounter pieces of software that are an absolute delight to use; they do exactly what we want, contain very few bugs, and are easy to use. But other times we encounter pieces of software that are absolutely horrible to use. They are full of bugs, crash all the time, and are unintuitive.

1.1 How code becomes software

1.2 The goals of code quality

1.2.1 Code should work

1.2.2 Code should keep working

1.2.3 Code should be adaptable to changing requirements

1.2.4 Code should not reinvent the wheel

1.3 The pillars of code quality

1.3.1 Make code readable

1.3.2 Avoid surprises

1.3.3 Make code hard to misuse

1.3.4 Make code modular

1.3.5 Make code reusable and generalizable

1.3.6 Make code testable and test it properly

1.4 Does writing high-quality code slow us down?

Summary

sitemap