DEV Community

Discussion on: OOP vs Functional Programming

Collapse
 
efpage profile image
Eckehard

OO was not created as a religion. Late back in the 80´s, when people tried to build large applications using procedural code, they often got lost in a swamp of side effects. OO was a way to build closed segments of code. Inside, an OO class is like a small procedural program, not much more. If we can use the principles of FP here, maybe we get better OO programs from that. Or maybe we do not need OO anymore? I´m not really sure.

I used OO programming for a long time. Some codes are now more than 25 years old and still do a good job. This is not, because OO is so great, but because it was easy to keep things running over such a long time. And most of this classes are really focused on a single task. OO was only used where it had a real benefit, not to follow any religion.

There is the old story about the banana, gorilla and the forest, that never was true. If you only want a banana, why should you use OO?? An OO-banana inherits lot´s of things you can use, it is a plant, it can grow, build seeds and so on. So, you inherit an ecosystem with lot´s of useful stuff. Many of the big class systems are not used because people are stupid, but because they want their objects to live in an ecosystem.

I can not see any reason why we should not use functional programming to build classes. It is not like "potato or rice". It is more: Which sauce do you want with your potatoes...