Logo

quadroid

Home
RĂ©sume
Tech Blog

The pain of cargo cult in software development

I came across the term "cargo cult" about a year ago on a StackOverflow comment. After googling it, I understood what the author was trying to convey. So, what does the term "cargo cult" mean in software development, and why is it so painful?

Cargo cult describes the blind following of a pattern without questioning it. (The term cargo cult originated from something that happened in World War II.) One of these unquestioned patterns that many developers have come across is Hungarian notation, which was widely accepted and followed for a long time without being questioned (in programming terms of course). Although no serious programmer follows this useless verbose convention anymore, there are tons of source code that follow this convention, which are ugly to read and waste a bunch of keystrokes per variable/class name to get the autocompletion going. So the convention, despite being known as obsolete for at least a decade, still generates a lot of pain for some people.

After reading the aforementioned post and learning about the programming problem that arises from blindly following conventions without trying to understand them, I thought about all the conventions I adhere to in my daily work. Of course, I have also followed conventions without question. Here are some questionable conventions I followed (these conventions were for C#):

Organize class members by regions.

The problem with this one is quite obvious: if you open a file for the first time, Visual Studio collapses all of the regions, which results in showing that a class contains constructors, properties, methods, and so on, but not which methods it contains or what constructors are available.

Luckily, I was able to get rid of this automatically using a regex:

^.#(end)(:Wh)region.\n

(Thanks, Brian Schmitt!)

All public members should be documented with XML documents.

After reading a bunch of the comments I wrote to satisfy this convention, I started deleting almost all of my comments. For example, a class Connection containing a property IsConnected: Gets a value indicating whether this instance is connected. Thanks, Captain Obvious!

There are many useful and very smart patterns in the programming universe, but there are at least as many useless code-littering cargo cults out there.

Don't be too lazy to save someone from the pain a useless convention/pattern generates, and refactor the cargo cult away!