This may be a religious argument, but it has been debated ad-nauseum here at my work whether all IF statements should include an ELSE clause - even if the ELSE clause only contains a comment stating that it was 'intentionally left blank'.
I have heard arguments for both sides: The 'For' camp - ensures that the codes has actually addressed whether the condition requires an ELSE clause The 'Against' camp - code is harder to read, adds too much noise
I am interested in any other points of view as I have to resolve this debate with an answer that would satisfy both parties.
Thank you for your help.
BTW: I did search StackOverflow for an answer to this and was unable to find one. If there is one, just include a link to it and close. Thanks.
Haskell's if is always ternary. So else is mandatory.
Requiring an
else
stinks. Use it when needed. All programmers understand the construct and the implication of a missingelse
. It's like a pointless comment that echoes the code. It's plain daft IMO.SQL Server 2000, 2005 at least.
You have to have a meaningful statement, which means a dummy assign or return data to client. I suppose I could use WAITFOR DELAY...
Seems like useless typing to me... and a possible cause for confusion. If you don't need it, don't put it!
No. If you don't need to run any code on the
else
side, you don't need anelse
clause.No. Guard conditions are a great example. You could nest the rest of the method logic in else clauses but it could get ugly really quickly.