3 ms·
> Avoiding mutating state means that either those objects have no attributes, or that the state can only be set on construction. (In FP speak, this corresponds
by lmm 9y ago
> Avoiding mutating state means that either those objects have no attributes, or that the state can only be set on construction. (In FP speak, this corresponds currying of common parameters. Or to an internal abstract type, if the constructor is private and you can only create it via a specific set of static methods).
I don't think the style you're talking about is something that most people would call "object oriented programming" ("modern" or otherwise). Indeed the usual name for the programming style in which you avoid mutating state is "functional programming".
- vog 9y agoMaybe, but the terms "class", "method" and "interface" are more commonly understood than "functor" or "natural transformation". So for better understanding by the general public it may make sense to offer an explaination in terms of OOP, even if what is described is more FP style than OO style.
- lmm 9y agoFunctors are functors, natural transformations are natural transformations; neither has much in common with classes, methods or interfaces. Functors are being used to achieve composition here, but the use of functors is an essential part of the pattern; talking about "composition-oriented programming" would be vague to the point of meaninglessness (every programmer believes they're being compositional), and there simply isn't an OO equivalent of open recursive types as far as I know.