4 ms·
> Why would you indent hat next line? There are lots of reasons someone might indent the next line. Maybe they were in a rush. Maybe they were distracted by som
by fredophile 11y ago
> Why would you indent hat next line?
There are lots of reasons someone might indent the next line. Maybe they were in a rush. Maybe they were distracted by something else while they were working. Maybe they were tired. Maybe they were drunk.
Mistakes will happen. Ideally wrong code will look wrong. All of the following examples do the same thing. If you know the code is supposed to call Foo() and Bar() if bVar is true, which of these examples make it obvious that something is wrong?
if (bVar) Foo();
Bar();
if (bVar)
Foo();
Bar();
if (bVar)
{
Foo();
}
Bar();
if (bVar)
{
Foo();
}
Bar();
The third, followed by the fourth, makes the mistake most obvious to me.