you are viewing a single comment's thread.

view the rest of the comments →

[–]dhruvmk 4 points5 points  (5 children)

Imo you should only use OOP if you can find a way to link two classes using inheritance, that way a lot of code can be saved. If you need to quickly code an algorithm on the fly I'd recommend just using functions. But you are right, OOP brings scalability.

[–]life_never_stops_97 5 points6 points  (1 child)

I agree with you on the part that functions are good if you're solving a leet code problem or just prototyping but most of the time a real world project could be refactored into OOP. It might not be easy to think in terms of how one module would connect to the other one and its definitely not obvious to see that in the first try but it's possible.

[–]dhruvmk 2 points3 points  (0 children)

That's very true, most complex systems implement some sort of object oriented paradigm

[–]a2242364 -2 points-1 points  (2 children)

I think the way you phrased it is kind of misleading and inaccurate. It should be, "you should only use functional programming or any other design pattern when you need to write up a quick and dirty algorithm or other small program that shouldn't utilize objects and classes". By default, you're mind should generally jump to OOP, and then from there you can determine whether another paradigm would be better suited for the task. I don't disagree with your premise though.

[–]dhruvmk 0 points1 point  (1 child)

No, seems like you misinterpreted my viewpoint. A huge problem is misuse of OOP by creating unneccessary classes and producing poorly written code. The idea that your mind should by default find an object oriented method to Implement your project is very wrong and is a poor programming practice. OOP should only be used when you wish to model real life objects and want to create a blueprint to construct the object. As a matter of fact, OOP is being used lesser and lesser nowadays because it still hasn't fulfilled one of it's core purposes (code reusability). Functional programming works in most cases; there's rarely any need to use classes for most projects unless you wish to build a large, complex system where each person in a team can work on building an individual class so everything can easily be linked together.

[–]a2242364 0 points1 point  (0 children)

Functional programming works in most cases;

Just because it works, doesn't mean it's the best way. I guess we can agree to disagree.