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
-
Some people do that style of empty if to make later refactoring obvious. I don't agree, but I've seen it before.
-
That is the worst example of speechless making code I have ever seen.
It's clean and obvious what it does. Yes it could be better but it could be a whole lit worse. And it even has comments. Bonus. -
codedoge6047yI find it hard to classify the above as "clean" when the following would have done the same thing:
if (!dict.ContainsKey(key)
{
dict.Add(key, value);
}
The comment is useless, the if statmeent is renundant and it uses twice as many lines. -
codedoge6047y@codedoge if you can't get a simple if-else statement right, what should I excpect for problems requiring more complex solutions?
-
codedoge6047y@okkimus I prefer to use different styles depending on the popular conventions of the language
-
@codedoge well if that leaves you speechless you obviously don't get out much
-
codedoge6047y@okkimus I find C# code with opening bracket on the same line just as ugly as I would find curlies on new lines when I read JS
-
codedoge6047y@Jonnyforgotten Meh, It's just the last thing in a long line of ridiculous code snippets I've been stumbling upon in the project.
-
codedoge6047y@Jonnyforgotten What irritates it's me is that the cleaner solution is even easier and more compact to write
-
I don't think code like that gets written, it has probably evolved into its current state. It possibly started off with "oh no my key exists, throw an exception", then they realised an exception was over kill, so the replaced it with a comment rather than changing it to the code you suggested.
-
tkdmatze4407yOf course the comment should be
// NOP
https://en.wikipedia.org/wiki/NOP
seen it often enough in my career, some companies refuse the not-operator in if clauses because it can be "overseen" that quickly
Related Rants
-
linuxxx32*client calls in* Me: good morning, how can I help you? Client: my ip is blocked, could you unblock it for m...
-
DRSDavidSoft28Found this in our codebase, apparently one of my co-workers had written this
-
linuxxx23*client calls* "hello, we forgot the password to our WiFi router. Could you reset that for us?" 😐😶😮...
Actual code
if (dict.ContainsKey(key))
{
//do nothing
}
else
{
dict.Add(key, value);
}
I'm speechless
undefined
wtf