Should 'if' statement always have an 'else' clause?

Jack picture Jack · Nov 23, 2009 · Viewed 87.4k times · Source

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.

Answer

jldupont picture jldupont · Nov 23, 2009

Seems like useless typing to me... and a possible cause for confusion. If you don't need it, don't put it!