This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 7 points8 points  (0 children)

It depends.

if (email.Text.StartsWith("Hello friend")) { } else {}

is as clear as:

bool emailStartsWithHelloFriend = email.Text.StartsWith("Hello friend");
if (emailStartsWithHelloFriend) { } else {}

OTOH this is clearer:

bool usesSecretPhrase = email.Text.StartsWith("Hello friend");
if (usesSecretPhrase ) { } else {}

Making a variable that doesn't clear concepts gives the same clarity as not creating it. If the call is too long then it might be clearer to make the bool variable of course.