L
lovecreatesbea...
The book `Code complete' mentions similar code snippets as the
followings , and talks about their advantages respectively.
But I think these code snippets are totally different in logic, and
their functionalities are different. They don't have comparabilities.
Am I right?
/*code 1*/
for (i = 0; i < N; i++){
if (cond)
DoSomething();
else
DoOtherthing();
}
/*code 2*/
if (cond){
for (i = 0; i < N; i++)
DoSomething();
} else {
for (i = 0; i < N; i++)
DoOtherthing();
}
followings , and talks about their advantages respectively.
But I think these code snippets are totally different in logic, and
their functionalities are different. They don't have comparabilities.
Am I right?
/*code 1*/
for (i = 0; i < N; i++){
if (cond)
DoSomething();
else
DoOtherthing();
}
/*code 2*/
if (cond){
for (i = 0; i < N; i++)
DoSomething();
} else {
for (i = 0; i < N; i++)
DoOtherthing();
}