---
title: "Cargo cult programming"
type: "antipattern"
slug: "cargo-cult-programming"
url: "http://localhost:3000/en/antipatterns/cargo-cult-programming.md"
description: "Ritual inclusion of unnecessary computer code"
---
# Cargo cult programming

> Ritual inclusion of unnecessary computer code

**Cargo cult programming** is a style of [computer programming](https://en.wikipedia.org/wiki/Computer%5Fprogramming "Computer programming") characterized by the ritual inclusion of code or program structures that serve no real purpose. Cargo cult programming is symptomatic of a programmer not understanding either a bug they were attempting to solve or the apparent solution (compare [shotgun debugging](https://en.wikipedia.org/wiki/Shotgun%5Fdebugging "Shotgun debugging"), [deep magic](https://en.wikipedia.org/wiki/Magic%5F%28programming%29 "Magic (programming)")). The term _cargo cult programmer_ may apply when anyone inexperienced with the problem at hand [copies some program code](https://en.wikipedia.org/wiki/Copy%5Fand%5Fpaste%5Fprogramming "Copy and paste programming") from one place to another with little understanding of how it works or whether it is required.

Cargo cult programming can also refer to the practice of applying a [design pattern](https://en.wikipedia.org/wiki/Software%5Fdesign%5Fpattern "Software design pattern") or coding style blindly without understanding the reasons behind that design principle. Some examples are adding unnecessary comments to self-explanatory code, overzealous adherence to the conventions of a [programming paradigm](https://en.wikipedia.org/wiki/Programming%5Fparadigm "Programming paradigm"), or adding deletion code for objects that [garbage collection](https://en.wikipedia.org/wiki/Garbage%5Fcollection%5F%28computer%5Fscience%29 "Garbage collection (computer science)") automatically collects.

## Etymology

[Cargo cults](https://en.wikipedia.org/wiki/Cargo%5Fcult "Cargo cult") are [millenarian](https://en.wikipedia.org/wiki/Millenarian "Millenarian") movements that arose in [Melanesia](https://en.wikipedia.org/wiki/Melanesia "Melanesia") under colonial rule, and inspired [Richard Feynman](https://en.wikipedia.org/wiki/Richard%5FFeynman "Richard Feynman") to coin the expression [cargo cult science](https://en.wikipedia.org/wiki/Cargo%5Fcult%5Fscience "Cargo cult science"). In Feynman's description, after the end of the Second World War practitioners believed that air delivery of cargo would resume if they carried out the proper rituals, such as building runways, lighting fires next to them, and wearing headphones carved from wood while sitting in fabricated control towers. "The form is perfect. It looks exactly the way it looked before. But it doesn’t work."

The term then became used more widely as a metaphor for empty rituals. The term "cargo-cult programming" appeared in version 2.5.1 of the [Jargon File](https://en.wikipedia.org/wiki/Jargon%5FFile "Jargon File"), a glossary of computing slang, released in January 1991\. The term "cargo cult" in anthropology, meanwhile, is increasingly avoided for failing to represent the complexity of Melanesian beliefs.

## Cargo cult software engineering

A related term to cargo cult programming in [software engineering](https://en.wikipedia.org/wiki/Software%5Fengineering "Software engineering") is _cargo cult software engineering_, coined by [Steve McConnell](https://en.wikipedia.org/wiki/Steve%5FMcConnell "Steve McConnell").

McConnell describes software development organizations that attempt to emulate more successful development houses, either by slavishly following a [software development process](https://en.wikipedia.org/wiki/Software%5Fdevelopment%5Fprocess "Software development process") without understanding the reasoning behind it, or by attempting to emulate a commitment-oriented development approach (in which software developers devote large amounts of time and energy toward seeing their projects succeed) by mandating the long hours and unpaid overtime, while in successful companies these might instead be consequences of high motivation instead of causes of success.

In both cases, McConnell contends that competence ultimately determines whether a project succeeds or fails, regardless of the development approach taken; furthermore, he claims that incompetent "imposter organizations" (which merely imitate the _form_ of successful software development organizations) are in fact engaging in what he calls _cargo cult software engineering_.
