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
-
Perfect example for the harm of stupid metrics like lines of code...
Int modulus is a single assembly instruction. -
@jespersh
That might indeed one of the rare cases where the unit test is shorter than the subject under test - while still covering all code paths and edge cases. -
I don't understand how this can be tolerated. Is this in a work environment, or? That would be weird. This isn't even tolerated in highschool. lol.
Is a number even? Hm, *me as junior dev*:
return (num % 2 == 0) -
You can optimize away all the "else" because each if is returning.
Otherwise I see no problem. -
Um ok....this is a little scary. I mean I admire this “dev’s” patience to type all that shit up, but the least he could’ve done was google how to check even instead of going this route and cracking his carpals
-
What's the default return? based on that, you can delete at least half those lines
-
hjk10156963y@Oktokolo but it's a hefty one. Not that it warrants this crap but modulo and divide are the heavies.
Let's say you don't know about modulo and don't know how build your own divide by two nothing remaining stuff.
At least notice that you have a binary option that can be solved with if else (false in the else).
That would have saved half the rules already.
This is called "programming efficiency"
joke/meme