|
by Eric Lippert via Fabulous Adventures In Coding on 2/1/2010 4:29:00 PM
Which is better style?
bool abc;if (Foo()) abc = Bar();else abc = false;
vs
bool abc = Foo() && Bar();
?
To me, this comes down to the question “is Bar useful solely for obtaining its value, or also for its side effects?” The stylistic choices should typically be driven by a desire to clearly communicate the semantics of the program fragment.
The metasyntatic names are therefore making this harder to answer, not easier. Suppose the choice were in fact between:
bool loginSucc
... [ read more ]
|