Zero 15
Clarity of code is a signal-to-noise ratio. We need our code to be as concisely meaningful as possible (not as cramped and crowded as possible, and not unnecessarily spread out over many pages). Whatever size provides the most accurate and quickest reading for trouble-shooting and enhancement is the best size.
On one of my past projects, we found ourselves able to remove a lot of dead code and as we added new features we were also able to simplify a lot of existing code. This is a very good thing, since code is a liability and functionality is an asset (I’ll elaborate more on that at a later date).
However, my manager was secretly reporting our progress in terms of lines of code/week. I was called on the carpet after some very productive weeks of producing unusually clean code. My manager’s problem was that we had been averaging over 200 lines less per week. By making the system cleaner and smaller, we were being reported as making negative progress, and were ordered to stop!
It’s just another “bad metrics” story, but it underscores an unspoken assumption that code should always grow bigger over time.
One non-zero-respecting practice is that of commenting-out code and leaving it. people have to scroll around the code, reading bits above and below, and so it is really just a speed bump for those who are trying to learn. It’s worse if the code is inside some nested level of a function than if an entire function is commented out. This is unnecessary, because a version control system holds the old code and can restore it if you really need it again (if not, consider a new VCS). Commented code is redundant with the VCS, in addition to being a nuisance.
Zero isn’t all really about comments, but about noise in general. Systems often have ‘dead code’, code which is never used but never deleted. When there are insufficient tests, one is unsure of coverage and cannot tell if a piece of code is being used or not. That means that code with zero use may have non-zero occurrences. In such systems, it can be very dangerous to remove code at all. Since the rule of zero is not respected, code accumulates.
Zero also will have us remove abstractions and interfaces when we no longer need them.
Zero tells us to remove tests when they’re no longer valuable.
Zero is a good idea.
I just located an old Jeff Atwood quote that lights up a few of the same synapses.
Trackbacks
Use the following link to trackback from your own site:
http://blog.objectmentor.com/articles/trackback/5717
Zero == Code Nirvana
re: “code is a liability and functionality is an asset”, hear, hear!. Looking forward to reading your thoughts about it.
”... if we wish to count lines of code, we should not regard them as “lines produced” but as “lines spent”: the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger.”
— E.W. Dijkstra, ‘On the cruelty of really teaching computing science’
>   if we wish to count lines of code, we should not regard them as “lines produced†but as “lines spent 
Be careful with that! Although you’re right, some folks could think that putting allot of statements in one line would improve the code! I think that metrics based on lines of code are useless altogether. Their only benefit is that they’re easy to measure. I’d rather measure such things as features implemented (with weight factors reflecting their complexity), test coverage and code clarity (get someone unrelated to the project to the code and measure the time she/he needs to understand what it does).
some folks could think that putting allot of statements in one line would improve the code! I think that metrics based on lines of code are useless altogether. Their only benefit is that they’re easy to measure. I’d rather measure such things as features implemented (with weight factors reflecting their
Classic exposition, I have also mentioned it in my blog article. But it is a pity that almost no friend discussed it with me. I am very happy to see your article.
When there are insufficient tests, one is unsure of coverage and cannot tell if a piece of code is being used or not. That means that code with zero use may have non-zero occurrences. In such systems, it can be very dangerous to remove code at all. Since the rule of zero is not respected, code accumulates.
By making the system cleaner and smaller, we were being reported as making negative progress, and were ordered to stop!
we were being reported as making negative progress
Once I knew only darkness and stillness… my life was without past or future… but a little word from the fingers of another fell into my hand that clutched at emptiness, and my heart leaped to the rapture of living. One can never consent to creep when one feels an impulse to soar. Optimism is the faith that leads to achievement. Nothing can be done without hope and confidence.People do not like to think. If one thinks, one must reach conclusions. Conclusions are not always pleasant. Science may have found a cure for most evils; but it has found no remedy for the worst of them all – the apathy of human beings.
nice passage. I like it…
Okey oynamak hiç bu kadar zevkli olmadi. Online ve 3 boyutlu okey oyunu oyna ve turnuvalara sende katil.
I like this page. I have read it carefully and wow really awesome.
All the ?ncident Off-Road RC Car appeared relating to Come july 1st 10 on the 400 block out about N. Orange colored Lane, all the San Bernardino criminal court account talked about.
All the victim’s 1:5 Scale RC Car list is now being withheld around the corner notice about members of your family.
Basically no other RC Monster Truck sorts of knowledge was first attainable to the lawsuit.
Slewing ring is also called slewing bearing, some people called: rotary support, swing support. English Name: slewing bearing or slewing ring bearing or turn table bearing, slewing ring in the real industrial applications is very wide.
This is really good idea. why not keep a copy of the iPhone data on computer without iTunes and you can restore the file to iPhone when necessary. good luck.