3 ms·
Generally,it is good to give advice to write clean code. Undoubtedly, clean code causes less problems than unclean code (e.g., overengineered, overmodularized,
by beeforpork 4y ago
Generally,it is good to give advice to write clean code. Undoubtedly, clean code causes less problems than unclean code (e.g., overengineered, overmodularized, or prematurely optimised).
Running speed tests on the much-cited mini-example with geometric shapes and their area is unfair and unrealistic, and it does not prove any point.
I think I can see where this is coming from: 'overly clean' OO style will split concerns into virtual one-liner functions without context distributed throughout the universe. For a simple problem, I prefer 'switch'. But that's not a good rule either. For anything extensible, like a GUI, 'switch' would be the wrong choice and virtual much better.
Programmers need to develop a feeling of appropriateness, and restructuring may be necesaary at times.
BTW, the manual loop unrolling in the article is broken and not advisable at all. I'd be angry in code review about such 'optimisations'.