DEV Community

Discussion on: SOLID Principle: Single Resposibility Principle

Collapse
 
efpage profile image
Eckehard

Sorry, but paradigms are not religion. You don't have to be either Catholic or Protestant.

There had been different ideas on what OOP should be in the past, but as implemented in C++ it was just a way to isolate parts of your code, thus reducing complexity. And it was a clever way to reuse code without loosing the single source of truth. It was never a holy grail the cured all your programming issues, specially with an increasing number of people that did not even know how to use these tools.

And how should they? Javascript initially had no class concept, and what we have now is only a very lightweight shadow of what classes should be. No encapsulation, no fine grained scoping.

You should explain a bit more, which "whoes" OOP could not cure? Maybe it is more a problem of your expectation. If you put enough spaghetti into a class, the result will still be spagehtti. This is the same with all paradigms.

Functional progamming makes your programs more reliable. But internally, a class works like a small programm, so there is absolutely no reason why you should not apply the principles of FP to class methods.

OOP was invented to solve the problems of large procedural codebases. But did people switch and write only OOP-code? No, they did not, They continued to write procedural code, nut now inside OOP-classes and only where it was appropriate. Just because we establish a new paradigms, this does not mean, we forget about anything we have learned before. We're just increasing our toolbox, nothing else.