CHAPTER 2 Writing Maintainable, Future-Friendly Code
else, re-indented it the way you like? That’s your brain not being able to
figure out the code because of how it looks. When everyone writes code
that looks different, everyone is constantly trying to parse the code before
being able to understand it. When everyone writes code that looks the
same, your brain can relax a bit as the understanding comes faster.
When you start thinking of code as communication with other devel-
opers, you start to realize that you’re not simply writing code, you’re craft-
ing code. You put extra thought into each keystroke because the code is
no longer just for a computer to execute, but for another person to under-
stand. Your code should clearly communicate its purpose to the casual ob-
server. Keep in mind, your code is destined to be maintained by somebody
other than you. Not only are you communicating with other members of
your team in the present, you’re also communicating with members of
your team in the future.
I recently received an email from someone working on code I wrote 10
years ago. Apparently, much to my shock and horror, my code is still being
used in the product. He felt compelled to email me to say that he enjoyed
working with my code. I smiled. My future teammate actually did appreci-
ate the coding style I followed.
leave YouRSelf ClueS wiTh CoMMenTS
If you know your enemies and know yourself,
you will not be imperiled in a hundred battles.
—Sun Tzu, The Art of War
Knowing yourself is important in life as well as coding. However, you’ll
never know yourself well enough to remember exactly what you were
thinking when you wrote each line of code. Most developers have expe-
rienced looking at a very old piece of code that they wrote and not having
any idea why they wrote it. It’s not that your memories are bad, it’s just