4 ms·
Aren't there other ways to solve this that are easy to refactor? For example, writing a standalone function for just the common parts of the horse and donkey ne
by trealira 3y ago
Aren't there other ways to solve this that are easy to refactor? For example, writing a standalone function for just the common parts of the horse and donkey neigh implementations, and if suddenly some things stop being common to both, move it into the horse or donkey implementations specifically.
Or, maybe this idiom (it's C++ but should apply to other languages with inheritance and virtual method equivalents, e.g. Java, C#). Why not something like this?
https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Non-Virtual_Interface https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Non-Virtua...