The Watchful Eyes of a Mobster — Hadi Zaher (CC BY-NC-ND 2.0)

What Kangaroos & Beachballs Can Teach You About Code

During some of my presentations I’ve told a funny story that has circulated around the internet. The story goes that a group of programmers working on Operation Phoenix added herds of kangaroos to a helicopter flight simulator, reportedly because the roo’s reactions to a helicopter could give away the location of a helicopter (or just for laughs).

To do so, they inherited code originally used to model infantry reactions to helicopters, changed the image from a soldier to a kangaroo, and called it a day.

The Aussies buzzed the virtual kangaroos in low flight during a simulation. The kangaroos scattered as expected, to nods and congratulations… and then the group did a double-take as the kangaroos reappeared from behind a hill and launched a barrage of weapon fire at the helicopter.

This is an amusing illustration of the Gorilla Banana Problem from classical object-oriented programming:

“The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” ~ Joe Armstrong, from Coders at Work

The problem is that class inheritance (by extension, the `extends` keyword in JavaScript) forces you to inherit everything from the parent class. This problem is easily avoided using object composition instead of class inheritance.

I retold this story during a visit to Australia. After the talk was over, my wife approached me laughing. She has heard me tell the story a few times.

She had been thinking I was talking about a real helicopter flight, and she was confused about how a group of Kangaroos got their hands on weapons and learned how to fire them at anything, and what on earth this had to do with programming.

She wondered to herself “why does he keep telling this story?”

It only dawned on her that I was talking about a software simulation this time because I told a bit more of the story to the Australian crowd:

According to an account by Dr. Anne-Marie Grisogono, head of the Simulation Land Operations Division at the Australian DSTO (Defense Science and Technology Organization) the programmers had not implemented missiles yet, so instead of missile fire, the programmers were shot down by large multi-colored beachballs.

I thought this story was funny the first time I heard it, but I’ve been laughing at “why does he keep telling that story?” a lot more.

Keep laughing.


How can you avoid the Kangaroo Beachball Problem?

Learn Prototypal OO & Object Composition with Eric Elliott


Eric Elliott is the author of “Programming JavaScript Applications” (O’Reilly), and “Learn JavaScript Universal App Development with Node, ES6, & React”. He has contributed to software experiences for Adobe Systems, Zumba Fitness, The Wall Street Journal, ESPN, BBC, and top recording artists including Usher, Frank Ocean, Metallica, and many more.

He spends most of his time in the San Francisco Bay Area with the most beautiful woman in the world.