Small matter of code style that I keep coming across.
Whether to write
if (thing) Action();
or
if (thing)
Action();
or
if (thing)
{
Action();
}
We should always use the braces to avoid introducing bugs when modifying the code manually or through merge tools.
For the reasons behind this, read the following:
- Omitting Braces: Not Just A Matter Of Style - DZone Java (archive)
- Making Wrong Code Look Wrong β Joel on Software
- Anatomy of a βgoto failβ β Appleβs SSL bug explained, plus an unofficial patch for OS X! (archive) - an example of a serious security flaw that would likely have not happened if braces had been in place.
