What is better coding practice for single-line code blocks following an if statement - braces or no braces? Just to avoid too many "Well, it depends on what language you're using..." answers, let's say for C#. In other words, which is better:
if(somecondition)
{
singleLineStatement;
}
Or
if(somecondition)
singleLineStatement;
if
andelse
match. If theif
is multiline and theelse
is single, they'll both be bracketed. If I have two single line components in theif
andelse
, then they'll both generally* be sans-braces. I don't feel the need to completely idiot-proof the code, because they keep making better idiots. (*) There are exceptions if braces help readability, such as when a single statement spans multiple lines. – Functionalism