logoalt Hacker News

munchleryesterday at 9:20 PM1 replyview on HN

Unions are simpler than subclasses and more powerful than enums, so the use cases are plentiful. This should reduce the proliferation of verbose class hierarchies in C#. Algebraic data types (i.e. records and unions) can usually express domain models much more succinctly than traditional OO.


Replies

Quarrelsomeyesterday at 9:38 PM

> so the use cases are plentiful

such as?

> This should reduce the proliferation of verbose class hierarchies in C#

So just as an alternative for class hierarchies? I mean good people already balance that by having a preference for composition.

show 2 replies