Skip to content
DevMeme
6132 of 7590
CodeQuality Post #6725 · source on Telegram

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

29
Anonymous ★ Top Pick This is the version of the quadratic formula you get when the PR reviewer's only comment is 'please add more descriptive variable names'
  1. Anonymous ★ Top Pick

    This is the version of the quadratic formula you get when the PR reviewer's only comment is 'please add more descriptive variable names'

  2. Anonymous

    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.”

  3. Anonymous

    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?

  4. Anonymous

    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

  5. Anonymous

    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

  6. Anonymous

    Refactoring the quadratic formula into enterprise vars: because 'a, b, c' is just Y2K for mathematicians

  7. Anonymous

    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

  8. @Grebenkin_Il 1y

    He can't even rewrite the formula normally...

  9. @gongchanM1 1y

    Now its time to figure out what is a coefficient A B and C

  10. @summitbc 1y

    unironically i would've done so much better with math in school if formulae were expressed as code. but more clearly than this image

  11. @azizhakberdiev 1y

    can't wait "played for absolute fools" meme about algebra

  12. @Bjastkuliar 1y

    Java monent

  13. @deadgnom32 1y

    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.

    1. @mrYakov 1y

      Make even_element iterator lol, clear and descriptive

      1. @deadgnom32 1y

        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

        1. @mrYakov 1y

          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 ?

          1. @deadgnom32 1y

            you are aware, that you reach INT_MAX in 14 iterations which are so fast, that its nearly noop?

          2. アレックス 1y

            prompt(“Could you please find the quadratic formula of…”)

        2. _ 1y

          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]

          1. @deadgnom32 1y

            while request to a server takes billions time longer

          2. @deadgnom32 1y

            well. for such a small function consisting of 3 lines loop, they can write it anew

      2. @deadgnom32 1y

        now figure out how to call them too. half_decade_numeral_system times_two_half_numeral_system

  14. Manuel 1y

    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

  15. @Eugene1319 1y

    How -b became -coefficientA Who did review it

    1. @blackjacksante 1y

      Nailed it

  16. @patsany_horosh_mne_v_dm_pisat 1y

    fr this should be like this at school

  17. @mrYakov 1y

    To be honest. Best way to do graphs is allow user to input target intervals. By list of points or math formula.

  18. @feralape 1y

    The quadratic formula is legacy code now, power series formula is my new best friend

  19. @alexe_sh 1y

    Then needs to be rewritten into code/LaTeX

Use J and K for navigation