Explain the gorilla-banana problem in inheritance.

Last updated 5 July 2026

  • You wanted a banana but got the gorilla holding it and the whole jungle: inheritance is all-or-nothing, pulling in unwanted state, dependencies, and behavior.

  • Result: tight coupling to the base class and bloated, hard-to-test subclasses.

  • Fix: favor composition by holding a reference to only the object you need and delegating to it.

  • https://dev.to/efpage/what-s-wrong-with-the-gorilla-2l4j
  • https://www.johndcook.com/blog/2011/07/19/you-wanted-banana/
  • https://medium.com/codemonday/banana-gorilla-jungle-oop-5052b2e4d588
  • https://medium.com/javascript-scene/the-hidden-treasures-of-object-composition-60cd89480381
  • https://medium.com/javascript-scene/master-the-javascript-interview-what-s-the-difference-between-class-prototypal-inheritance-e4cd0a7562e9
  • https://medium.com/@Ranjit_Saimbi/unwanted-gorillas-1d27eaa2eefa
All Object-Oriented Programming interview questions