Functional and object-oriented projects simplify various types of extensions. Given the discriminatory union in the functional setting, it is easy to determine any number of functions that work on this type, but it is difficult to add additional types to the type, since you will need to go back to add an additional case to each function whose template matches the type. On the other hand, given the base type (or interface) of the OO installation, it is easy to add new subtypes, but adding new operations to the base type is difficult because it potentially requires changing existing subtypes to add each new implementation.
Depending on the type of extensibility that is most significant for a given task, a functional or object-oriented approach may make more sense, so itβs nice to have both options. One popular approach is to use the functional approach βin the smallβ and the OO approach βin generalβ (for example, it is mentioned in this podcast with Luc Hoban).
source share