Conditionals when used correctly can make verbose code concise and readable. However, there are enough examples of them being used incorrectly that can scare most people away from them completely.
That is one of the most unreadable conditionals I have ever seen. It returns true of false depending on whether or not $year is a leap year. However this is a bit of an extreme example. Just because something can be used badly doesn’t mean we cannot use it well. If that was the case then most Hollywood actors would be out of work.
The following code sample does a very simple thing. It calls a sort method with a sort direction depending on a flag.
if (flag) {
sort(SORT_ASC);
} else {
sort(SORT_DESC);
}
This is quite verbose, but it does not use conditionals. It can be modified to be even more readable with the use of a simple conditional:
The benefit of doing it this way is that the logic of the sort direction is contained in the function call. There is no need to look at its surrounding lines to figure out what is going in. This means less work, and a win from my point of view.