Often, programmers consider Object Orientation and Functional Programming to be mutually exclusive forms of programming.
Usually, two camps clash ...
For further actions, you may consider blocking this person and/or reporting abuse
Hi, I love your post ! You have a really deep understanding of both paradigm and you changed my point of view. I have my two cents on this topic:
Yes, I was thinking the same until I discovered algebraic data types from FP which are a more expressive way of representing things. Nowadays I don't think in term of classes and objects (which are limiting) but in term of types
To be honest I didn't understood this part. To be more precise which kind of polymorphism (generics, ad-hoc, etc.) is used there ? Or is it about late binding that let some flexibilities in the run time creating a more dynamic program ?
Finally I am also using both paradigms: FP for modeling data and functions and OOP for protocols and communication between entities
Hi,
Thanks a lot for your feedback. I'm glad you share the same vision.
I should probably add an exemple for the dependency part. I would add this example below, what do you think ?
Let's consider two classes: Service and Client.
In a system without polymorphism, Client directly calls a method on Service. Client directly depends on Service both in the source code and at runtime.
If we introduce an interface ServiceInterface, which Service implements, Client no longer depends directly on Service. Instead, Client depends on ServiceInterface. Now, the source code dependency is inverted: Service depends on ServiceInterface, and Client depends on ServiceInterface, but not directly on Service. However, at runtime, Client will still depend on an instance of Service, or another class that implements ServiceInterface.
Thanks, that's a great example. I better understand