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...
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!!!
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.
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)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
Yep! That's why I think a mix of both is usually best—at least for the code I write.
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.
Writing
.
before name of function is calledEncapsulation
, 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#
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.
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)