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
With inheritance, the methods defined by DigestibleOfMarshalable could be imported directly, and if I wanted to override them it wouldn't be as problematic.
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!