Monday, March 7, 2011

Short-circuiting logic. Which one would you rather maintain?

Which one would you rather maintain?

Explicit logic?
(
    !string.IsNullOrEmpty(letter_pressed)
    && x.CompanyName.StartsWith(letter_pressed)
)
||
string.IsNullOrEmpty(letter_pressed)

Implicit logic?
string.IsNullOrEmpty(letter_pressed)
||
x.CompanyName.StartsWith(letter_pressed)

Does lesser code always trumps the longer code?

No comments:

Post a Comment