18

Mystery of the day: why some developers can't decide on a code style. Let's count:
- two types of brace placements
- three types of assignment spacing (with, without spaces, and aligned with extra space)
- two types of clause spacing
- mixed case in the first char of a variable for no apparent reason(?)
- bonus: unneeded parentheses

At least in ONE thing the person was consistent: no space between parameters!

WHY GOD.

Comments
  • 8
    Atleast they got one variable right, myJunk 😅

    Are you sure it's the same dev? Cause god help us if it was.
    But then if it wasn't, that's also scary why so close code looks so radically different.
  • 2
    @C0D4 I can only guess. There was no versioning system before I came by to upgrade PHP.

    And rant, of course. That's free, so great.
  • 1
    I'm not going to lie, some of my stuff ends up like that. Not for lack of consistency so much as an evolving taste in what I prefer to do.

    I generally update the patterns as I come across them based on what I'm going with at the time but occasionally I miss things and even more likely, I'm not entirely decided when I change them and a week later they need to be updated again, only this time I'm not working on that part of the app so I don't think to do it.
  • 2
    @M1sf3t I understand when code style evolves, but you mentioned exactly what's lacking: if someone changed code just above the "wrong one", update the rest of it too!

    IDEs are great on that: you configure a code style, press a shortcut, and magically all the file gets formatted.
    Also, linters exist for a reason: it's important to keep your style consistent if you ever plan to get outsider help. And even if you don't, practise it.
  • 3
    Can we please just point out the redundant cancer that is ^([ ]+) in this code?

    Why are there so many spaces in a "one of" search and why didn't they just use \s ?
  • 1
    @stonestorm lol, surprise surprise. That's a space AND A TAB!

    I only noticed it after the screenshot, so I couldn't add, but thanks for pointing it out.
  • 1
    @igorsantos07 But but... Does that even work? I've never been mad enough to try.
  • 0
    @stonestorm I guess so. In the end, \t and an actual tab are the same, right?

    I wouldn't suggest anyone to try, tho - unless you want to make someone else mad.
  • 0
    If the code is that bad, just use a linter to format all the code in the repo (php cs fixer 😉)
  • 1
    Wow. That's not legacy, that's.... Unusable.

    for with count...
    unnecessary variable init for list
    ereg
    error propagation seems very wrong...
    list with missing check if empty for users...

    There is only one line I find appropriate in this whole code.

    Find it. XD
  • 1
    This code is a train wreck
  • 0
    What is that crossed equals sign in the last if statement? Is it something IDE replaces, like != ?
  • 1
    @Dozak Font ligatures
Add Comment