“Clean” Code, Horrible Performance
Conversation
Notices
-
cancel (cancel@merveilles.town)'s status on Wednesday, 01-Mar-2023 05:23:11 JST cancel -
Vertigo #$FF (vertigo@hackers.town)'s status on Wednesday, 01-Mar-2023 05:24:58 JST Vertigo #$FF @Faibbus @cancel The problem isn't applying clean code to a few floating point multiplications. I think that misses the point.
I think what he was trying to convey was the dogma that is clean code can be just as dangerous as premature optimization.
Like all things in software development, performance needs to be measured. OOP works great at course-grained modularity. The problem comes when trying to over apply the technique, which a lot of people do in Enterprise computing to structures that are quite small in scope. As someone who has had to maintain enterprise level software for several decades, I can confirm unbashedly just how difficult it is to work on large code bases that are extremely polymorphic. It is nearly impossible to work on such code bases without having some dynamic debugging environment active. It is nearly impossible to statically infer the correct behavior of a program just by reading the source code, which significantly impacts the ability to code review.
Now, Casey is talking about performance issues, and I'm talking about actual correctness issues. But they both have common roots: dogma.
-
Faibbus :unverified: (faibbus@framapiaf.org)'s status on Wednesday, 01-Mar-2023 05:25:05 JST Faibbus :unverified: @cancel My point was that this is a terrible example to apply OOP. Because there is no benefit to the added complexity. So I'm not sure why you assume I did not pay attention…
Judging “Clean code” on a few multiplications is somewhat like judging a fish on its ability to climb a tree. Expect bad result.
I also suggested the quadrilateral example because it would make slightly more sense to have polymorphism there as it won't be described by just a height and a width.
Adrian Cochrane repeated this. -
cancel (cancel@merveilles.town)'s status on Wednesday, 01-Mar-2023 05:25:07 JST cancel @Faibbus I can tell you either didn’t watch or didn’t pay attention because the non-OOP version of the code is less complicated
-
Faibbus :unverified: (faibbus@framapiaf.org)'s status on Wednesday, 01-Mar-2023 05:25:08 JST Faibbus :unverified: @cancel
Dumb fishes that can't climb trees…The example is just a few float multiplications, so yes, going over the top to create classes and introduce gratuitous complexity is just wasted performance.
I love how «adding a concern» is just adding another float computation…
I would enjoy watching the “array version” with other type of shapes (say random quadrilateral).
In my experience, “performance” first → terser code → errors/bugs.
A wrong but fast answer is a worse waste of resources.
-