3 ms·
> With such polymorphism all hope is lost to be able to know the things that can happen. Implementations of the virtual method are not closed - they could be co
by AnimalMuppet 8y ago
> With such polymorphism all hope is lost to be able to know the things that can happen. Implementations of the virtual method are not closed - they could be coming from anywhere in the codebase.
Well, they could be implemented in any class that derives from the ancestor class that declared the virtual function. Unless you have one main base class, that should be a very small subset of the code. What's more, it has to have the same name. A recursive grep should show every implementation in the codebase.
- jstimpfle 8y agoReformulated "all hope is lost". In terms of ergonomics, I'd say having to recursively discover implementations is quite a stretch from reading a simple switch block that contains all the possible continuations case-by-case. Psychologically, obstacles like this can prevent you from maintaining the code.
- tigershark 8y agoIn OOP polymorphism is the way. In functional programming, if you have exhaustive pattern matching, then that is the best answer. Given that the examples are in Java 8 I would use without doubt polymorphism.