Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
nibor48775yIf only there was some sort of development methodology using tests that could catch these types of errors!
-
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.
-
Swan11095y@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.
-
@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.
-
I see shit like this all the time. It's a failure to see the forest for the trees.
-
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. 🧐 -
nibor48775y@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.
-
@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.
-
@nitwhiz wondering what school my man here is going to 🤣 and wondering if mit students see these thingd
-
Well, some setters modify the value and return the modified value afterwards, so here's that.
Still no great design, but still 'a' design. -
@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.
-
@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?
-
@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.
Related Rants
Someone two years into a degree wrote this. What the actual fuck.
rant
code
wtf