Hacker News new | ask | show | jobs
by yiransheng 3276 days ago
Inheritance based OOP models tree-like entites well, where hirachy is defined and clear cut. Unfortunately, lots of real life domains are best expressed by graphs - commonly a DAG. You need to pay attention to your edges and not just the nodes. Inheritance based OOP gives you one keyword to express your edges: extend, and it's horribly inadequate. Mutatable state is not a issue in Java OOP, lacking the expressive power is.
1 comments

Trees can be modelled with sum types, the mathematical dual of product types (records). Java doesn't have sum types and so inheritance has to be used to encode them.