Clean code, horrible performance.The performance part is actually not going to matter in anything I’m working on, but I do agree with this:
This is actually one of the reasons that — unlike “clean” code advocates — I think switch statements are great! They make this kind of pattern very easy to see. When your code is organized by operation, rather than by type, it’s straightforward to observe and pull out common patterns. By contrast, if you were to look back at the class version, you would probably never notice this kind of pattern because not only is there a lot more boilerplate in the way, but “clean” code advocates recommend putting each class in a separate file, making it even less likely you’ll ever notice something like this.
There’s quite a few abstraction practices that look clean, but in practice, make things harder to understand.