The Quadratic Formula Refactored by a Clean Code Zealot
Description
This image is a two-part meme satirizing the dogmatic application of 'clean code' principles to mathematics. The top section displays the standard quadratic formula, labeled with a large red 'X'. An accompanying list criticizes it for using 'Single-letter variable names (bad),' containing 'magic numbers,' and making 'no sense.' The bottom section presents a 'fixed' version of the formula, marked with a green checkmark. This version replaces the concise mathematical notation with verbose, programmatic names like 'solutionOutput,' 'coefficientA,' and 'TWO_CONSTANT.' The bullet points praise this version for having 'Descriptive variable names,' 'No magic numbers,' and being 'Easy and makes sense.' The humor stems from the absurdity of applying software development's readability rules to a universally understood and highly efficient mathematical formula. It mocks the idea that verbosity always equals clarity, highlighting how context is crucial when applying coding standards. For developers, it’s a relatable jab at over-engineering and the misinterpretations of coding best practices, often seen in less-experienced programmers
Comments
29Comment deleted
This is the version of the quadratic formula you get when the PR reviewer's only comment is 'please add more descriptive variable names'
Quadratic formula PR after review: now lives in QuadraticRootResolverImpl, TWO_CONSTANT and FOUR_CONSTANT are Spring-injected, latency doubled - but hey, SonarQube is green so it’s “clean code.”
Nothing says 'senior engineer' quite like turning a universally understood mathematical formula into an enterprise-grade abstraction layer where TWO_CONSTANT needs its own named constant - because what if the value of 2 changes in the next sprint?
When your junior dev takes 'no magic numbers' literally and extracts `TWO_CONSTANT` and `FOUR_CONSTANT` in the quadratic formula - because apparently mathematical constants aren't self-documenting enough. Next PR: renaming π to `CIRCLE_CIRCUMFERENCE_TO_DIAMETER_RATIO_CONSTANT`. At least the code review will be... descriptive
Code review on the quadratic formula: replaced a, b, and c with coefficientA/coefficientB/coefficientC and extracted TWO_CONSTANT and FOUR_CONSTANT to appease “no magic numbers”. Build passes; roots don’t - turns out ± isn’t an operator and we’re still doing integer division
Refactoring the quadratic formula into enterprise vars: because 'a, b, c' is just Y2K for mathematicians
When your linter bans magic numbers so hard that 2 becomes TWO_CONSTANT, you’ve turned O(1) algebra into an RFC - next bikeshed: naming the ± operator
He can't even rewrite the formula normally... Comment deleted
Now its time to figure out what is a coefficient A B and C Comment deleted
unironically i would've done so much better with math in school if formulae were expressed as code. but more clearly than this image Comment deleted
can't wait "played for absolute fools" meme about algebra Comment deleted
Java monent Comment deleted
I had this situation, when I needed to make an alternate loop execution with if(i%2){}else{} colleagues wanted me to get rid of the magic number and put it into a constant. when I suggested to call the constant two, they weren't satisfied. Comment deleted
Make even_element iterator lol, clear and descriptive Comment deleted
there were another 2 numbers it was a loop producing comfortable tick step for graphs. like 1 5 10 50 100 500 1000 5000 10000... and they wanted *2 and *5 to be constants too Comment deleted
Actually, it should be stored into cloud, so each time you need it, you should auth to your server, then fetch it. Why you dont know how to design modern apps ? Comment deleted
you are aware, that you reach INT_MAX in 14 iterations which are so fast, that its nearly noop? Comment deleted
prompt(“Could you please find the quadratic formula of…”) Comment deleted
In that case making [2, 5] a constant may be overkill but at least it's not entierly stupid. Suppose you then want 1 2 5 10 20 50 …, you could just change it to [2, 2.5, 2] Comment deleted
while request to a server takes billions time longer Comment deleted
well. for such a small function consisting of 3 lines loop, they can write it anew Comment deleted
now figure out how to call them too. half_decade_numeral_system times_two_half_numeral_system Comment deleted
Once in a project in which I was working management added sonar lint, which required us to not use magic numbers even when it didn't make any sense. So we created a file in the root of the project that exported all the numbers we needed as constants with their numeric values as names Comment deleted
How -b became -coefficientA Who did review it Comment deleted
Nailed it Comment deleted
fr this should be like this at school Comment deleted
To be honest. Best way to do graphs is allow user to input target intervals. By list of points or math formula. Comment deleted
The quadratic formula is legacy code now, power series formula is my new best friend Comment deleted
Then needs to be rewritten into code/LaTeX Comment deleted