The Developers Code
What Real Programmers Do
by Ka Wai Cheung
Version: P1.0 (February 2012)
Copyright 2012 The Pragmatic Programmers, LLC. This book is licensed tothe individual who purchased it. We don't copy-protect itbecause that would limit your ability to use it for yourown purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copywith other members of your team, with friends, or via file sharing services. Thanks.
Dave & Andy.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Cartoons courtesy of Mark Anderson, reproduced with permission of the artist. http://www.andertoons.com
Table of Contents
Copyright 2012, The Pragmatic Bookshelf.
Early Praise for The Developers Code
This is the next Pragmatic Programmer a guide for the beginner, a reminder for the expert, and a wonderful chunk of wisdom about the craft (and life) of a developer.
Derek Sivers, founder of CD Baby, sivers.org |
Ka Wai Cheung has written a book for professional developers seeking a code they can live by. This is not a book replete with conventional, find-it-in-any-blog ideas but a very powerful, focused approach to the craft and realities of professional programming.
If you are looking for a rehash of stale, sterile rules for programming, this is not the book for you. But if you are seeking a perspective on what creating software is, or if you want a set of guidelines laden by real-world experience, this is a book you need.
Bob Walsh, author and founder of 47 Hats |
Packed with delicious lessons yet consumable in bite (byte?) sized chunkstheres a lot to be learned in these pages. Take some time and learn from someone whos been there.
Adam Hoffman, senior development lead |
A great book filled with lots of hints, tips, and lessons learned in the fast-moving world of the modern-day programmer; a must-read for anyone working as, or with, a developer.
Acknowledgments
In the fall of 2010, with much of the original draft complete, I began pitching this book to several tech publishers. While I received some great feedback, I wasnt able to land a deal. The prevailing argument from most publishers was twofold: books like this typically dont sell, and in order to make it a worthwhile investment, I needed a bigger following.
Andy Hunt and Dave Thomas saw things differently. And so, first and foremost, Id like to thank Andy and Dave for sharing my belief that this book has a place in our industry. Im absolutely humbled to have it added to the great collection of works from the Pragmatic Bookshelf.
A book like this desperately needs a great editorone who tells it like it is and sees the content from 1,000 feet above when the author is entangled in the weeds. Id like to thank Brian P. Hogan for being a fantastic one throughout the entire process. This book is leagues ahead of where it initially was, in both its content and its approach.
A very special thanks to Mark Anderson of Andertoons.com. His creative cartoonsand witare strewn all over these pages. They provide a wonderful extra dose of levity and personality to the final product.
Thanks to Derek Sivers, Bob Walsh, Caspar Dunant, Colin Yates, Juho Vepslinen, Steve Cholerton, and Kim Shrier for generously donating their time to critically reviewing each and every chapter.
Much of the inspiration for this book came from the experiences Ive had at We Are Mammoth, the web development shop I started with Craig Bryant in 2006. For the past five years, weve continually challenged ourselves, questioned the way we go about our work, and openly exposed our opinions to each other. Thanks to my teamCraig, Michael, Mustafa, Tom, Sam, Anthony, Jennifer, Grant, and Lindsayfor teaching me new lessons daily.
Copyright 2012, The Pragmatic Bookshelf.
Chapter 1
Introduction
Ive been had by code. Twice.
The very first time was when I took a programming class during my freshman year of college. It was a mandatory course for the curriculum I had decided to enroll in. It wasnt like what I had seen in so many movies during my childhood. I didnt type in a few simple commands, press Enter
, and watch a trash-can robot say hello.
There wasnt even a trash-can robot in this class. Instead, it was about pointers, memory allocation, and object instantiation. I was too in the weeds to see what all of it meant. However, the evidence was overwhelmingly clear: programming was not for me.
I wanted to be an artist or perhaps a mathematician. I wanted to be both creative and exactboth right- and left-brained, as they say. Programming seemed to lean too far to the left, and no other career options I could think of let me play in both worlds simultaneously. I was lost.
Just a couple years later, the Internet boom changed the landscape of programming. Suddenly, it was real-world, it was approachable, and it had a lot to do with design. It valued both artistry and logic almost equally. For the first time, I really could foresee myself enjoying this work. I could now channel my passion for creativity and logic into web applications. So, I returned to programming, albeit with great apprehension.
Truth be told, I also came back to it for an entirely different reason. For that two-year hiatus, I studied many other subjects that seemed to have too many unanswered questions. Devising the Grand Unified Theory in particle physics or finding the largest prime number? Impossibly ambitious and daunting undertakings, for sure. They just werent for me. In addition, that course on existentialism didnt clear things up either. As a young adult, I simply wanted answers , not more questions .
Programming. The very subject I had once eschewed was now my refuge. After all, computer science was man-made. All the answers had to be there. I yearned for a career where answer seekers like me could thrive, where you turned elixirs of code into always-happy customers, comrades, and clients. The rules were already written. We just had to build. All the obstacles existed solely in code, I thought.
In my second return to programming, I was duped again, because this was certainly far from the truth.
1.1 Who Is the 21st-Century Programmer?
As I would find out over the next fifteen years, programming isnt a job for the reclusive. It certainly is not about the ber-nerd sitting in a dimly lit basement, sweating away for months on end, and then emerging with the final product in all its glory.