3 ms·
> This is very useful when you want polymorphism. > Writing those delegators is a pain in the butt. What's a scenario where you'd be exposing a large numbe
by cturner 13y ago
> This is very useful when you want polymorphism.
> Writing those delegators is a pain in the butt.
What's a scenario where you'd be exposing a large number of delegators? Reading this made me think - maybe your class hierarchy needs to be abstracted more deliberately into structs-with-interfaces vs domain logic classes. (It's more likely I just haven't thought about the kinds of problems you are thinking of.)
- thomasahle 13y agoWhat about something like Java's `AbstractList` and `AbstractSet`? These save you a lot of typing when implementing the huge `List` and `Set` interfaces.
- mercurial 13y agoFair point. The problem is solved in Haskell by having default implementation in the typeclass, leaving the programmer with only a few methods to implement (eg, 'equals' is defined in terms of 'unequals' and vice-versa, implement the one you want to get the rest of the typeclass working). That said, that's a fairly rare case. Classes with such a large surface are often a code smell.