The Gorilla, Banana Problem
A famous quote by the creator of Erlang:
I think the lack of reusability comes in object-oriented languages, not functional languages. Because 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.
Ahh, the Object oriented paradigm can seem like everything at first to developers. All the simple examples you see online can mold your mind and indoctrinate your sole into believing the OOP is the best paradigm that was ever invented.
So a new project comes along and I think back to the Class I wrote some time back, it’s only natural for a developer to think of these things. So great, I’m going to reuse my code and all I have to do is look for the darn class in the other project somewhere on my computers directory.
I set off looking for that shiny class, it’s in the forefront of my mind. Wait.. I’m going to need the parent of that class. Errr… The parent’s parent too and all of the other parents. I’m sure I got this, I think to myself as I start seeing objects nested within the classes - guess I’ll need them too! I got this!!
Well actually, no I don’t, I’m slowly sinking into the armpit of doom and losing confidence in my programming abilities - I’ve wasted oodles of time and energy into that little shiny class. Blah, Foooey…
So the story above is fictional, a figment of my imagination as I sit here and sip on some dark roast coffee and ponder of software. Guess I’m lucky that I’m more interested in functional techniques and functional languages: using pure functions, using functions as arguments and return values, as higher order functions.
As Joe Armstrong says, such code is easier to reuse.