this not homework question, question result of discussion friend.
i searched lot not find reliable source establishes answer proper reasoning here @ mecca of programmers.
which of following 2 ways of coding better:
if(a) { if(b) .... else if(c) .... }
or
if(a && b) ... else if(a && c) ...
i searched , found http://en.wikipedia.org/wiki/cyclomatic_complexity useful still not make out final choice.
please provide relevant reasoning well.
cheers!
i think without optimization first method should faster.
since in 1st method check a
once , b
or c
. if b false
there 3 checks(comparisons).
but in second check a
twice if b
false
(once if b
true
). there 4 checks if b
false. compiler optimize both same.
Comments
Post a Comment