Posted by Kevin Pang on 10/7/2008 | Comment Comments (34) | Tags: ,

Proverbs are used to express universal truths or life lessons in a short and memorable fashion.  I find that they are a great way to keep things in perspective, both in life and in work.  Because of this, I have assembled 10 programming proverbs that every developer needs in their arsenal.

1. There is no smoke without fire

Relax. It's probably just another fire drill

Poorly designed code tends to manifest itself through some common tell-tale signs.  Some examples of these are:

  • Giant classes and/or functions
  • Large blocks of commented out code
  • Duplicated logic
  • Deeply nested if/else blocks

Developers often refer to these as code smells, but personally, I think the term "code smoke" or "code fumes" is more appropriate as it implies a higher sense of urgency.  If you don't address the underlying problem it will come back to burn you later on.

2. An ounce of prevention is worth a pound of cure

Ok, I'm convinced

Toyota's assembly line of the 1980s was famously efficient due to its revolutionary approach towards defect prevention.  Each member of the assembly line was given the ability to halt production when they noticed a problem in their sector.  The idea was that it was better to halt production and fix the problem as early on as possible than to continue producing faulty units that would be tougher and more costly to fix/replace/recall later on.

Developers often make the faulty assumption that productivity = cranking out code quickly.  Many programmers dive straight into coding without a second thought towards design.  Unfortunately, this Leeroy Jenkins approach towards software development tends to lead to sloppy, fragile code that will need to be constantly monitored and patched -- perhaps even replaced altogether down the line.  Ultimately, productivity must be measured not only in how much time is spent writing it, but also by how much time is spent debugging it.  A short term gain may prove to be a long term loss if one isn't careful.

3. Don't put all your eggs in one basket

A software team's bus factor is defined as "the total number of key developers who would if incapacitated, as by getting hit by a bus, send the project into such disarray that it would not be able to proceed".

In other words, what happens if you suddenly lost a key member of your team?  Would business continue as usual or would it grind to a halt?

Unfortunately, most software teams fall into the latter category.  These are the teams that turn their programmers into "domain experts" who only deal with requests that fall into their area of expertise..  At first, this appears to be a fairly reasonable approach.  It works for the automaking assembly lines, why not for software development teams?  After all, it's unreasonable to expect each member of the team to be intimately familiar with each and every nuance in the application, right? 

The problem is that developers cannot be easily substituted and replaced.  And while the pidgeon-hole approach works fairly well when everybody is available and accounted for, it quickly falls apart when "domain experts" suddenly become unavailable due to turnover, sickness, or even freak bus accidents. It is imperative that software teams have some sort of redundancy built in.  Code reviews, pair programming, and communal code go a long way to foster an environment where each developer is at least superficially familiar with parts of the system outside their comfort zone.

4. As you sow, so shall you reap

The Pragmatic Programmer has this to say about the Broken Window theory:

Don't leave "broken windows" (bad designs, wrong decisions, or poor code) unrepaired. Fix each one as soon as it is discovered. If there is insufficient time to fix it properly, then board it up. Perhaps you can comment out the offending code, or display a "Not Implemented" message, or substitute dummy data instead. Take some action to prevent further damage and to show that you're on top of the situation.

We've seen clean, functional systems deteriorate pretty quickly once windows start breaking. There are other factors that can contribute to software rot, and we'll touch on some of them elsewhere, but neglect accelerates the rot faster than any other factor.

In short, good code begets good code and bad code begets bad code.  Do not underestimate the power of inertia.  No one wants to be the one who has to clean up sloppy code, but neither does anyone want to be the one that makes a mess out of beautiful code.  Write it right and your code will have a far better chance at standing the test of time.

5. Great haste makes great waste

Managers, clients, and programmers are getting more impatient by the day.  Everything needs to be done and it needs to be done now.  Because of this, the temptation to throw together hacks and quick-fixes becomes very tough to resist.

No time to properly unit test a new feature?  Oh well, it works for the one test run you put it through.  You can always come back to it later!

Mysterious object referencing error when you try to access property Y?  Whatever, just throw a try/catch block around the code.  We've got bigger fish to fry!

Sound familiar?  It's because we've all done it at some point in time.  And in certain instances, it is justifiable.  After all, we have deadlines to meet and clients/managers to satisfy.  But do it too often and you'll soon find yourself with a very unstable code base full of hotfixes, duplicated logic, untested solutions, and porous error handling.  In the end, you have to strike a balance between getting things done and getting things done right.

6. Look before you leap

The term "Agile Development" is used and abused frequently these days, often as a way for programmers to justify ignoring the dreaded planning/designing phase of software development.  We are creators, and as such we derive pleasure from seeing actual progress made towards a finished product.  Surprisingly, UML diagrams and use case analysis just don't seem to satisfy that desire.  So, we developers often start off coding without any idea of what we are doing or where we are going.  It's like heading out for dinner when you haven't yet decided where you want to go.  You're hungry so you don't want to waste time finding a restaurant and booking a table.  Instead, you just hop in your car and figure you'll think of something along the way.  Only, it ends up taking you longer because you have to make a bunch of U-turns and stops at restaurants that end up having too long of a wait.  True, you'll probably find your way to food eventually, but you probably didn't end up with the meal you wanted and it probably took a lot more time and hassle than it would have had you just called and booked a reservation at a restaurant you wanted to go to.

7. When the only tool you have is a hammer, everything looks like a nail

See?  I *told* you Active Record would work for this project!

Programmers have a tendency to get tunnel vision when it comes to their tools.  Once something "just works" for us on one project, we tend to insist on using it for every project therafter.  It can be a pain to learn something new and, at times, highly unsettling.  The entire time we're thinking "it would have been easier had I just done it the old way!".  Enough of these moments and we will simply go with what we know, even if it isn't a perfect fit for the task.

It's easy to stick with what you know, but in the long run it's much easier to pick the right tools for the job.  Otherwise you will be fitting square pegs into round holes for the rest of your career.

8. Silence is construed as approval

 

I see nothing! Nuh-thing!

This ties in with the theory on broken windows and programming inertia, only on a larger scale.   The programming community is just that, a community.  Each programmer is a reflection on the craft.  The more bad code that is released into the wild, the more it becomes the status quo.  If you don't make an effort to write good, clean, SOLID code, you will find yourself having to work with it on a day-to-day basis.

Likewise, if you see poorly designed code written by someone else, you should make the effort to bring it up with the creator. I should note, however, that tact ought to be employed in such a situation. In general, programmers are willing to admit that they do not know everything there is to know about software development and will appreciate the gesture.  We all benefit when we help each other out.  Turning a blind eye to problems only perpetuates them.

9. A bird in the hand is worth two in the bush

There is a time and place to discuss system architecture and refactoring opportunities, and a time to just get things done.  It is important to weigh the pros and cons of revamping something that already works just to make it cleaner.  It's an admirable goal, of course, but there will always be code that you want to restructure.  The programming world simply changes too frequently for code to not get outdated.  But at some point you have to provide value to your customers.  The simple fact remains: you can't do two things at once.  The more time you spend refactoring old code, the less time you spend creating new code.  Striking a balance is critical to enhancing as well as maintaining your application in a timely manner.  

10. With great power comes great responsibility

Software has undoubtedly become an integral and vital part of our lives.  Because of this, practicing good software development is more crucial than ever.  It's one thing to have a bug in a game of Pong, it's another to have one in the guidance system of a space shuttle or air traffic control system.  Slashdot recently posted an article describing how a minor glitch in Google News singlehandedly evaporated $1.14 billion in shareholder wealth.  Events such as these demonstrate how much power we wield.  It's a little frightening to think that the code you write today, whether you intend it to or not, may one day be recycled and depended upon for mission-critical applications.  Write accordingly.

Do you have any proverbs you feel should be added to this list?  Feel free to let me know in the comments!

Enjoyed this post? Share it with others!

Related posts

Comments

Steve Gricci
Steve Gricci on 10/7/2008 11:36 AM Great Post Kevin, I agree 100%.
Nemlah
Nemlah on 10/7/2008 1:16 PM My personal favorite: Assumption is mother of all fuckups..
Kevin Pang
Kevin Pang on 10/7/2008 1:33 PM Casey Charlton suggested via Twitter a couple proverbs that I thought were appropriate as well:

1. "Shit happens"
2. "The only certainty is change"
Chris
Chris on 10/7/2008 9:25 PM "If it ain't broke, don't fix it"

I've seen way too many programmers trying to reinvent the wheel. The same holds true for over-complicating: if the problem is bloated, the solution is doubly so.
Joshua Hayworth
Joshua Hayworth on 10/7/2008 9:27 PM Another one I picked up at a former employer:

"Always be able to get back to the place when you knew you were right"

-- Don Haney
ritchie
ritchie on 10/7/2008 11:33 PM "In other words, what happens if you suddenly lost a key member of your team? Would business continue as usual or would it grind to a halt?"

Until you get a decent-sized team (like a Brooks Surgical Team), the answer will likely be the latter, despite redundancy. A 2- or 3- or even 4-person programming team, if one person is hit by a bus, will have immediate and severe issues.

Not unique to programming: what do you do if you're shooting a film and the main actor gets hit by a bus? There are some times when redundancy can't keep you perfectly on track.

You can add redundancy, but beyond a fairly small size, adding programmers only slows you down. Many professional teams (like sports teams) solve this by having their extras train hard but sit on the bench during games unless they're needed. Unfortunately, most programming teams don't do (or can't afford) this.

The bus number is a useful statistic, but it's just an indicator to be mindful of how much information is locked in your team's brains. Many (most?) successful software projects were just a couple guys hacking stuff together. If Ken Thompson had gotten hit by a bus in 1969, would I have a UNIX workstation and a C compiler? Microsoft didn't grow from 1 to 100 by acting like today's Microsoft.
Rohan Almeida
Rohan Almeida on 10/8/2008 3:47 AM Nice article. especially the accompanying pictures. well done!
john
john on 10/8/2008 6:06 AM In addition to point 7: programmers are often constrained by management to the tools they can use. Either they must use the tool that is 'cool' at the moment or more likely, the tools that the department has expertise in. There's no point in personally embracing new technology when there's 20 other programmers in the dept. that won't. Licence key prices also cause issues: Lots of places won't pay for you to use certain tools even if they are close to essential for your job if you can get by using others (i.e. why buy TOAD when there's sql*plus).

julio
julio on 10/8/2008 6:13 AM It´s easy to walk over water or to develop over requirements, but both must be frozen.
ZagNut
ZagNut on 10/8/2008 8:12 AM Good post!

Question about #4, though:
A problem here is the sense that a developer has to have the power to go ahead and do this. If you are unfortunate enough to have a supervisor or lead who micromanages your output, you quickly begin to overlook fixing bad regions of code you find to prevent a Spanish Inquisition about why you did such-and-such. On the other hand, should developers be left unchecked?
John Catherino
John Catherino on 10/8/2008 8:32 AM As a 20 year software veteran, this one applies regularly, and usually devastatingly:

Problems that go away by themselves; return by themselves.

If you cannot explain how a code or configuration change directly corrects the observed problem; though it may appear to have gone away... it is very likely to return.
Kevin Pang
Kevin Pang on 10/8/2008 8:36 AM @John Catherino

I like that one. :-) Very astute observation.
Luke Francl
Luke Francl on 10/8/2008 10:44 AM I like: "When you see hoof prints, think horses, not zebras." (Also from the Pragmatic Programmer). Basically, when there's a problem, it's probably something common, not extraordinary.
Stephane Grenier
Stephane Grenier on 10/8/2008 11:13 AM Great post! I couldn't agree more with #1. It's amazing how often people just let bad code sit there and smolder forever, hoping that they'll never have to deal with it. Little do they realize that with time the cost of fixing it will add up, and faster than they realize!
Oren
Oren on 10/8/2008 11:20 AM Always code as if the programmer following you is a homicidal maniac who knows where you live.
Sage
Sage on 10/8/2008 12:44 PM How about, "shit breaks" and "code for load". Bad code and bad practices are exposed when under heavy load. Code your application so that when it is under heavy load, you arent spending your time trying to figure out why it sucks.
Rich
Rich on 10/8/2008 4:29 PM I think it was Bruce Eckle who said, "If you see hoofprints in your code, think horses not zebras."
Matt Brandenburg
Matt Brandenburg on 10/8/2008 4:47 PM K.I.S.S. Keep It Simple Stupid, very important basic ideology in my opinion.
Terry Smith
Terry Smith on 10/8/2008 6:36 PM Source control is not optional.
Ardi
Ardi on 10/9/2008 12:53 AM Nice!!!
Can I post this in my blog?
I will mention the source ;-)

Thx
Kevin Pang
Kevin Pang on 10/9/2008 1:14 AM @Ardi

You can post an excerpt/preview of a paragraph or two if you want and link to the full article. Please don't copy the entire post verbatim though.
Goji Juice
Goji Juice on 10/9/2008 4:46 AM Nice and informative article...
Vince Maguire
Vince Maguire on 10/9/2008 11:31 AM Simplicity scales.
Dave Schinkel
Dave Schinkel on 10/9/2008 9:58 PM Unfortunately the main problem and cause of all these things usually is bad management from top down to the development team due to lack of expectations and standards. We have managers in IT that should never be managers are are sometimes there only because they kissed ass way too many times.
Schoonzie
Schoonzie on 10/10/2008 10:11 PM Great post. I think I've probably make the mistake of number 7 in the past, but I think I'm a bit more reasonable now.
asp.net
asp.net on 10/11/2008 7:02 AM great article, thx
RichFromProg4sci
RichFromProg4sci on 10/12/2008 9:40 AM Great article! I'm always struck by how well software development lends itself to writing down succinct nuggets of wisdom. And how much any programmer can benefit from taking a little time to read them.
Ives
Ives on 10/12/2008 4:06 PM Awesome article and it makes me not feel alone in the fucked up world of web development. Now I know I'm going to the heaven of developers when I die hehe
ElvisFromhell
ElvisFromhell on 10/15/2008 12:51 AM You can't polish shit.
[translated from german]

Images are perfectly chosen.
Ole Phat Stu
Ole Phat Stu on 10/15/2008 10:11 AM Always use a configuration management tool, even if you are working alone.
Malkit
Malkit on 10/15/2008 10:28 AM I read this somewhere - "Think twice, code once"

- Malkit
Marco
Marco on 10/29/2008 10:47 AM Way to go!, really great post, although there are several other proverbs that should be added in next edition.

Personally there are two I could think of "It's no use crying over spilt milk" (leave the past in the past and learn from your own mistakes) and another one I read a time ago, "Failing to Plan means Planning to Fail"
Agustin
Agustin on 11/20/2008 11:49 PM Learn to say no, if you think it's going to take 1 hour, say it will take 3, 'cos that's how long it's going to be...
WebDevVote
WebDevVote on 11/26/2008 6:01 PM You're been voted !
Track back from www.webdevvote.com/.../10_Programming_Proverbs_Every_Developer_Should_Know

Add comment


 

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]