3 ms·
Interesting. It is more a design pattern rather than a language thing. But it is always good to design a consistent API across similar but not related classes.
by haifeng 12y ago
Interesting. It is more a design pattern rather than a language thing. But it is always good to design a consistent API across similar but not related classes.
- dougk16 12y agoAgreed, with all languages I'm aware of this is purely a design concern, outside the scope of language specification. However I'm currently working on a library that relies heavily on this so-called static polymorphism, so you can imagine what a pain it is whenever I do a major refactor. Without formal relationships between classes, methods, etc., it's much more of a manual and error-prone process, as far as introducing inconsistencies in the API. This has led me to ponder some language-level (or even just IDE-level) ways to specify loose relationships between disparate constructs that would make such iterative API development easier. No brilliant insights yet though. :)
- haifeng 12y agoStructural subtyping are mostly close to static polymorphism. After all, we just don't like inheritance, not dynamic polymorphism. Besides, interface and trait are not really inheritance although closely related.