1. 25
  1.  

  2. 9

    Indeed.. And I’ve also seen plenty of other really dumb things.. Recently at my place I found the following around line 300 in a perl script of 1200 lines..

    database_server = database_port = 3306; database_login = root; database_password = ;

    All I could say is FACEPALM. First, these should be in a config file. Second, this file was committed to SVN for over 7 years. Third, the RPM package contained these creds.

    Tl;Dr. DevOps engineer looking for work with a more modern codebase, with even a minimal amount of code review…

    1. 4

      I wonder who that author mentioned is?

      1. 3

        Probably Yashavant Kanetkar.

      2. 3

        Some of the easiest fixes are simply not having operators like ++. Or banning them from your style guide. The “cleanest” usage of that can be replaced by += 1, and the statement can’t be composed, limiting the silliness.

        Another decent win is probably not having the assignment operator return its value. x = y = z = 0 might suffer a bit, but it’s a price to pay to destroy messy code.

        I’m a fan of “everything is an expression”, but it doesn’t mesh well with stateful languages. Better to cut the root.

        1. 2

          FWIW, Clang emits a warning for multiple modifications with no sequence point in-between, and unsequenced modification + access, like the examples in the post.

          1. 1

            Considering people write things where correct usage requires 10 or 20 lines of method calls in the exact order, and think this is good programming, I’m going to go with “yes” here.

            1. 1

              I think the reason why this kind of code manifests, and all of the complicated, rube-goldbergian gegaws that get hacked together is because programmers like to think that they’re clever. Slap together an unexpected combination of operators in a multifold side-effect having statement? You’ve gotta be pretty clever to do that, pretty clever to understand it, and even more clever to change it later.

              May the programming gods save us from the clever programmers.