36
Swan
5y

Someone two years into a degree wrote this. What the actual fuck.

Comments
  • 2
    @AleCx04 you know what I'm thinking. :D
  • 0
    @Haxk20 I honestly couldn't tell you. There was loads like this.
  • 2
    If only there was some sort of development methodology using tests that could catch these types of errors!
  • 2
    @nibor Are you unit testing setters?
  • 1
    It's just a honest mistake, nothing to rant about. We do shit like this all the time. That's why yoda conditions etc. were invented. The only problem here is that they didn't just let IDE generate the setter.
  • 0
    @gronostaj there's an awful lot of honest mistakes everywhere, I suppose it's just a shame to see someone who went through the same education I did seems to have not picked up basic concepts. Everyone makes mistakes but the frequency is concerning.
  • 0
    @gronostaj of course! Aren't you?
  • 1
    @nibor I'm not. I have them generated by the IDE. It's trivial code that you can't get wrong if you use your tools.
  • 2
    I see shit like this all the time. It's a failure to see the forest for the trees.
  • 0
    What's with that variable assignment? As is, if name is a global variable the function won't perform as expected (unless the assignment is reversed).

    Thanks for the entertainment, though. 🧐
  • 1
    @gronostaj I've seen trivial code that was generated by the ide be modified by someone later on, so I personally like to have test coverage on them if possible.
  • 0
    @gronostaj we do shit like that all the time? That's a joke, right? No offense but if you seriously do shit like that you really don't understand certain concepts or this is just not the right thing for you to do.
  • 2
    @nitwhiz wondering what school my man here is going to 🤣 and wondering if mit students see these thingd
  • 1
    Fired.
  • 1
    May be because I do not have 2 years degree, I do not understand his logic behind
  • 1
    public string Name { get; set;}

    Like a boss
  • 3
    Well, some setters modify the value and return the modified value afterwards, so here's that.

    Still no great design, but still 'a' design.
  • 3
    @Emphiliis But this takes a value, modifies it to another, out of scope, value, and returns it. It's not setting anything at all, other than flawed expectations.
  • 3
    @powerfulparadox Oh yea, true. This hurts. Ouch
  • 1
    I first thought this was a fluent setter at first, but it's worse
  • 0
    @CodeMasterAlex They intended to assign `name = newName`, typed `newName = name` instead. As I said, it's an honest mistake. People make mistakes sometimes. That's why we have type checking, unit tests and yoda conditions. Are your tests always green and the code works on the first try?
  • 1
    @gronostaj It's not only the assignment but also the fact that the setter returns a value. Although this works and is legit, in general, setters should not return a value just like a getter should not set a value.
  • 0
    @CodeMasterAlex Okay, that's weird
  • 0
    Wow priceless useless XD
Add Comment