Cargo Cult Programming

October 13, 2004 3:25 PM

During World War Two, a number of Pacific islands that had previously been left undisturbed by civilisation found themselves home to military bases. These bases had airstrips on which landed planes full of clothing, food, and all the other things you need to run an outpost.

After the war, the bases were vacated and dismantled, leaving behind a lot of bemused islanders. When the strange people were around doing strange things, food fell from the sky. When they left, it stopped.

So some islanders began to mimic the activities of the soldiers who had left. They sat in towers, carved new equipment out of wood, lit signal fires, and waited for the food to fall again. Anthropologists dubbed these religious activities "cargo cults". (Wikipedia)

Sometimes, I find myself performing cargo cult programming1.

A piece of code works. I don't really understand how it works or what it's doing. But if I copy it over here, tweak the edges and poke it a few times, I'm pretty sure I can get it doing what I want it to do well enough that I don't have to know how it works.

I'm not really programming, I'm just standing on someone else's runway waving a torch, hoping it'll work.

You don't need me to tell you that this is a Really Bad Thing. The resulting code is error-prone, brittle, inefficient, and don't even think about trying to remove duplication or foster reuse.

That said, sometimes you have a task that's about important enough to deserve an hour's work, but that would take a day to understand. You can either abandon the task as unscheduleable, or you can cargo-cult it. "So long as you understand you don't know what you're doing", I tell myself with a knowing wink. "It will be fine."

This explains how I could have spent the last year on a project that uses Maven, written several build targets (and a tool to build and test against multiple databases and application servers), and still have no real clue how Maven works.

1 This is related to cargo cult software engineering, but not the same since I'm talking about code, not process.

5 TrackBacks

Listed below are links to blogs that reference this entry: Cargo Cult Programming.

TrackBack URL for this entry: http://fishbowl.pastiche.org/mt-tb.cgi/588

TITLE: Cargo Cult Programming URL: http://blogs.slcdug.org/rhordijk/archive/2004/10/13/620.aspx IP: 216.7.186.30 BLOG NAME: Bob's Delphi Stuff DATE: 10/14/2004 03:26:16 AM Read More

TITLE: Cargo Cult Programming URL: http://blogs.slcdug.org/rhordijk/archive/2004/10/13/620.aspx IP: 216.7.186.30 BLOG NAME: Bob's Delphi Stuff DATE: 10/14/2004 03:26:16 AM Read More

TITLE: Are you part of the Cargo Cult? URL: http://blogs.k12dev.com/dlundberg/archive/2004/11/02/165.aspx IP: 65.115.95.253 BLOG NAME: Dave's Rants DATE: 11/03/2004 11:05:09 AM Read More

I'm fairly sure you could accurately gauge the maturity of a programming team by the amount of superstition in Read More

I'm fairly sure you could accurately gauge the maturity of a programming team by the amount of superstition in Read More

3 Comments

Interesting post (I can certainly relate to it).

From a Maven perspective, I'm kind of encouraged by it too - Maven should be simple enough that you can use it to build existing projects without having to know too much about it.

Certainly when it comes to starting new projects, or adding Maven to an existing one that uses something else to build, that's going to require more knowledge, but hopefully that's simple enough too :)

Amen to that. I don't want to have to wade thru docs and acquire a "deep" understanding of some software, just so that it can "save me time and effort".

If I can download it and get it to run ASAP and display something interesting, then I have handles into the source, where I can start to "tweak the edges and poke it a few times", as you say, and mold it into the tool that I want, without ever pulling my hair out wondering what really makes it tick.

FWIW that's also what burns me about FSF software. When I think about AT&T UNIX man pages of the 70's, it is apparent that the FSF has forgotten the fine art of examples on the man page. Apparently I am supposed to grok the whole man page, and use the tool based on first principles, instead of being a philistine and finding an example that I can twiddle with.

Just to be an ass... ;)

[pedantic]
I think your behaviour would be better classified as voodoo-programming.
__
The use by guess or cookbook of an obscure or hairy system, feature, or algorithm that one does not truly understand. The implication is that the technique may not work, and if it doesn't, one will never know why.
__
whereas cargocult programming is generally meant to mean imitating the behaviour of experienced programmers, although that behaviour has no real purpose or effect (other than making you look stupid). Example would be writing Mock-Classes although you don't know what they are, don't need them and are never going to use them.Both have an entry in the Jargon Files.
[/pedantic]

*SCNR*

Comments are no longer being accepted for this blog entry. If you really want to make your voice heard, you can always email me.

Previously: Close to a Legend

Next: No Swap for You!