Seeing that Uncle Bob is making a new version of Clean Code I decided to try and find this article about the original.

  • lolcatnip@reddthat.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    5 months ago

    A function name can be misleading just like a comment can, in the same scenarios and for the same reasons, plus it’s harder to update because you have to change it in at least two places.

    • dandi8@fedia.io
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      edit-2
      5 months ago

      And yet, outdated comments are far, far more common than outdated function names.

      Also, if you’re changing a comment which explains the “what”, you should likely change the method name, as well.

      It’s important for the client to know what the method does by looking at the name, so why would you duplicate your effort?

      • lolcatnip@reddthat.com
        link
        fedilink
        English
        arrow-up
        3
        ·
        5 months ago

        And yet, outdated comments are far, far more common than outdated function names.

        Because people don’t try to squeeze a complete description of what a function does into a single identifier, which is what you you would have to do if you want function names to take the place of comments. I for one don’t want to strip all the spaces and punctuation out of my comments so I can use them as function names, and I really didn’t want to read someone else’s code written in that style.