> I believe that it is best-practice to use {} for any code block
> regardless of its length.
I know that a lot of people agree with you.
Obviously, I don't. I think that turning one line into three just adds
bulk and cuts clarity. I don't buy the "argument from maintainability"
- it's not at all hard to add the {} as needed and, in the VS
environment (ie, with a nice auto-formatter) it's all but impossible
to misread
if (tst)
statement1;
statement2;
> We have made that part of our coding standards here.
How ... special. Does that have anything to do with try/catch syntax?

Signature
www.midnightbeach.com
Helge Jensen - 31 Aug 2005 16:39 GMT
/me bears wood to the stake and looks for matches ;)

Signature
Helge Jensen
mailto:helge.jensen@slog.dk
sip:helge.jensen@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
gmiley - 31 Aug 2005 18:57 GMT
> We have made that part of our coding standards here.
How ... special. Does that have anything to do with try/catch syntax?
---
Not directly - no, except that in our case where it's required to use
{} for all code blocks, questions such as the original "Why does
try/catch require {}" do not exist.
---
I don't buy the "argument from maintainability"
- it's not at all hard to add the {} as needed and, in the VS
environment (ie, with a nice auto-formatter) it's all but impossible
to misread
if (tst)
statement1;
statement2;
---
Buy the argument or not, but when you have to go through 10,000 lines
of code littered with evaluation/flow-control statements that do not
use {} and find that you need to add more instructions to those blocks,
you will be pounding your head wishing it had been done in the first
place.
I agree, VS does a nice job at formatting, but as general practice
(language/environment/etc non-specific) you cannot write code, as a
team-member, that relies on the IDE you prefer to use.
It's not just a matter of readability, or maintainability - it's a
matter of propper programming practices in a multi-author environment.
I'm not telling anyone they HAVE to do it a certain way - I was simply
stating my opinion on how to make the argument moot. Create standards
to be adhered to, one of which was the requirement of {} for all
code-blocks regardless of how many lines it might be at the time.