DEV Community

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

 
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)