O'Reilly logo

Hello, Startup by Yevgeniy Brikman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Clean Code

Code is for people

Programming is the art of telling another human what one wants the computer to do.

Donald Knuth

As a programmer, you’ll spend less than 50% of your working hours on coding tasks [Orsini 2013]. Of the time spent coding, the ratio of reading code to writing code is well over 10:1. And of the tiny fraction of time you actually spend writing code, 80% or more of it will be maintenance code: that is, modifying or fixing code that already exists [Martin 2008, xx]. If you work eight hours a day, you’ll be lucky to spend five minutes writing new code (see Figure 6-1). It turns out that your job as a programmer isn’t to write code but to understand code.

hstu 0601
Figure 6-1. Developer time breakdown

This is why clean code matters. Clean code is code that is optimized for human understanding. Remember, startups are about people, so the most important thing about code is not how fast it runs or what algorithm it uses, but the impact it has on the people that use it. You should write clean code not for idealistic reasons, not because some book says you have to (not even this one), not because spaces are prettier than tabs—but because you will spend the vast majority of your time as a programmer understanding and maintaining code. Make it easy on yourself.

Let’s try an experiment. Imagine you come across this Java code:

public class BP {
public void cvt ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required