3 ms·
> I seem to be one of few people that don't see any inherent conflict between OOP and FP It really depends on which aspects you see as essential to the paradig
by kybernetikos 9y ago
> I seem to be one of few people that don't see any inherent conflict between OOP and FP
It really depends on which aspects you see as essential to the paradigms. If you define functional programming as programming that makes use of HOFs, or that encourages referential transparency, then you can combine those learnings with OOP nicely.
It's also possible to characterise them as in opposition. For example, you say
> Good OOP is none of that. It's simply associating data with code that operates on it
If I wanted to characterise FP in opposition to that, I would say that Good FP is keeping the state (i.e. the data) dissociated from the code in order to gain the benefits of referential transparency, composability, reusability and abstraction (attaching code to state massively reduces your ability to abstract).
FP tends to encourage the reuse of generic datastructures and vocabularies much more, while OOP likes to encourage you to create your own datatypes with their own vocabularies.
Personally these days I like coding in an OO style with lots of learnings taken from FP, but the worldview that sees these as different poles on a continuum is not difficult for me to appreciate.