DEV Community

Discussion on: Is Object-Oriented Programming "Dangerous"?

Collapse
 
oenonono profile image
Junk

That's what intuitive means, man. It means it's similar to something you already understand. So for human beings, there are three broad categories of intuitive. Biological/environmental, sociocultural, and trade/domain. Some things are intuitive because they exist in nature. Some things are intuitive because they are taught in childhood. Some things are intuitive after having experiences in a specific domain.

OOP is intuitive based on all three, arguably, but definitely based on the latter two. Most languages people use have subjects, objects, verbs, and adjectives. We learn those languages as children and use them with all our co-workers, not just other programmers.

Advanced math, however, is only intuitive based on the third.

Thread Thread
 
furkanthehuman profile image
Furkan Aksoy

Okay, you are right about intuition but still, functional programming does not mean advanced math. At least not always.

OOP has strong logical and academic bases. But in day to day life, we don't use words like polymorphism or encapsulation.

Most of the functional code is things like, being side effect free or use of high order functions. So things like category theory and stuff is mostly proof of concept.
The pareto principle

Thread Thread
 
combinatorylogic profile image
combinatorylogic • Edited

Please stop pretending that natural languages have anything to do with this useless and fully artificial notion of "objects" that any of the OOP definitions is dealing with.

steve-yegge.blogspot.com/2006/03/e...

Thread Thread
 
furkanthehuman profile image
Furkan Aksoy

What? I did not say anything about natural languages

Thread Thread
 
combinatorylogic profile image
combinatorylogic

Yep, sorry, I misread your answer in a context of this thread.

 
sixtynine profile image
Dan

In day to day life, polymorphism is when you get a can of pepsi instead of a bottle of coke, and the way we get our food in a restaurant is strongly encapsulated :)

Thread Thread
 
shovelmn12 profile image
shovelmn12

It doesn't matter... At the end of day to write oop takes more time more code and harder to refactor

For example

list.map(mapToWhatever)
.filter(onlyBlue)
.map(getChildren)
...etc

Easy to read and understandable, who ever thinks its not shouldn't be programming.
The same 4 lines in oop would be maybe 30 including 3 different interfaces and 4 different classes and to refactor such a thing is much more complicated than adding one line that describes exactly what you want.

Plus look closely lots of the leading frameworks are fp... Express react redux flutter swiftui Compose etc...

FP + Declarative = easy to read and understand

Thread Thread
 
oenonono profile image
Junk

Yep! That's why I think a mix of both is usually best—at least for the code I write.

 
sixtynine profile image
Dan

My point is that OOP is intuitive because it tries to model the reality.

I don't deny the virtues of FP, I use it.

As well as OOP.

Thread Thread
 
akashkava profile image
Akash Kava • Edited

list.map(mapToWhatever)
.filter(onlyBlue)
.map(getChildren)

Writing . before name of function is called Encapsulation, even in FP, you are using some OOPS, remove . and then write everything, and see how many problems will arise!!!

By the way you can do that in C#

list
   .Select( x => ((x.Property1, x.Property2)));
   .Where(x => x.Property1 > 20)
   .Select(x => x.Property2);

The biggest advantage here is, strong typing, and class relationships allows IDE to provide intellisense and provide compile time errors way before the code's execution. These are other benefits of OOPS, though such things are possible in FP as well but I don't think the level of advance IDE matches anywhere near to OOPS IDEs have already mastered.

There is no end of such argument, I said in the beginning and even I am repeating, you have to use best of both worlds !! Don't try to overdo by doing everything in FP just to show off, its not worth it.

Thread Thread
 
oenonono profile image
Junk

But as someone else has already pointed out, that example is OOP—and, in fact, may only be FP depending on how the functions passed into the methods are actually implemented.

list is the object (the subject)
map, filter, are methods of the object (the verbs)