Skip to main content

Command Palette

Search for a command to run...

Banana Gorilla Jungle --OOPs

By Sahil Dudhal

Published
2 min read
Banana Gorilla Jungle --OOPs
S

Computer Science Student Developer Learner linux enthusiast


" The problem with object-oriented languages is they have got all the 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

This Famous Quote explains the class depend on class problems. you want to use 'Banana' but ends up importing Gorilla then the whole things that gorilla depends on life. Other objects and classes that is jungles.

Credit : https://creator.nightcafe.studio/creation/hswj3jsGCJ3QCeF2nwkx

This is a problem of class inherits form class


Why is this called Banana-Gorilla-Jungle Problem?

Suppose in OOPs we want to use banana which in class gorilla which is in class Jungle. But someone just want to call banana alone. Banana is encapsulated. So, this might look like.

Jungle.getAnimalByName("Gorilla",1).getBanana();

How might this have happened?

Without a good knowledge of object-oriented system, For the system that we have class Banana-Gorilla-Jungle we just finished coding class Jungle and then adding up some features Then call it class Gorilla then adding some more features, and then call it glass Banana Now we got:

class Jungle
{
    // features
}
class Gorilla extends Jungle
{
    // Some More Features
}
class Banana extends Gorilla
{
    // Additional features
}

Someone might do this through import without recognizing it, especially for the language that one class belongs to one file

import Gorilla 
        //code how Banana related to Gorilla
import Jungle
        // Code have Jungle related to Gorilla

So that we tend to end up seeing these unintentional wired inheritance and dependency gorilla holding a banana in the real life.