S
S
Sergey Konovalov2015-09-28 23:34:14
Programming
Sergey Konovalov, 2015-09-28 23:34:14

Which design is correct?

There is a method that searches for a matching user, returns true if the user is found, false otherwise. Actually the question is what design is considered preferable?
return selectedUser.Any() ? true : false;
or

if (!selectedUser.Any())
                    return true;
                return false;

Advise what to read on the correct design of the code

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Martyanov, 2015-09-28
@vilgeforce

The second construction, IMHO, is readability hell, the indents correspond to the weather on Mars. In my opinion it is better to write like this:

if (!selectedUser.Any()){
    return true;
}
else{
    return false;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question