One of the most self-aware learnings to come out of OOP is "favor composition over inheritance". Even in OOP, inheritance is an anti-pattern. All roads lead to FP.
-
-
Replying to @jdegoes
I call bullshit on that. I use trait inheritance all the time for my (type)classes. Enriching data structures by adding new operations out refining existing ones, adding or refining cases, fields, etc., is a great way to incrementally define libraries.
3 replies 0 retweets 6 likes -
Replying to @Ngnghm
It's pretty widely accepted in OOP that implementation inheritance should not be favored if composition is feasible. Implementation inheritance leads to scattering out domain logic over a hierarchy, bugs due to violations of implicit contracts, and other issues.
3 replies 0 retweets 1 like -
Examples are welcome
1 reply 0 retweets 0 likes -
I'm using this all over the place (gotta learn ppx): module Foo type t = ... module Marshallable type nonrec t = t let marshal = ... let unmarshal = ... end include (DigestibleOfMarshalable (Marshalable) : DigestibleS with type t := t) end
2 replies 0 retweets 1 like -
what about (shortened) ``` class type ['a] marshalable = object method marshal : ... end class ['a] digestibleOfMarshalable = object(self : # marshalable) method digest = ... end class ['a] foo = object method marshal = ... inherit [_] digestibleOfMarshalable end ``` ?
1 reply 0 retweets 1 like
Thanks for the suggestion. I'm not familiar enough with OCaml's object system to comment, but I'll experiment with it. That said, inasmuch as it works (multiple inheritance?), it's precisely an example of using inheritance to simplify something that is a huge pain with FP\OOP.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Read my blog!