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
-
abcdev30758yI personally prefer
If(something)
Dowork();
If there are no use of else. Some of my coDevelopers do not like it. But who care. -
I learnt that the else part is redundant if you are returning something in the if statement.
-
Wtf seriously?? It would make.me think 'uh oh someone forgot something here' or 'hmmm looks like this code is not finished yet'. So, your colleague is an asshole and he really should stop doing that. It sucks. Big time.
-
I've heard of companies requiring this as once a serious bug happened because something wasn't in an else, I actually don't think it's bad practice to write this necessarily.
It doesn't bog down your runtime and really isn't all that confusing, and has a chance to stop or catch bugs -
@tylerhartwig If something wasn't in an else it is a logic error. You should never write empty statements, it's confusing for others, makes you write more code that isn't used and really does not aid to higher code quality but lower instead.
-
Empty else brackets are not wrong. There are plenty of books talking about this topic (my favorite one is "code complete").
About the fact that it is confusing, well... You can simply leave a comment there:
// This is here for blah blah blah and for now there is no use for it
All of the above, IMHO :)
Saludos! -
@javierojeda also if it's a standard in a work place.. It can be communicated once, at the first code review of a new person
-
joaorecio668y@creeebz , send him/her a note saying.
You better stop with the fucking empty clause elses. Or else{}
😂😂😂
So sick of my colleague who keeps writing:
if (something) {
doWork();
} else {
}
He insists that it is the best code style to include the empty else clause. WRONG YOU #!*&@!
undefined