Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks. One day, while debugging some of his colleague's code, Miguel noticed that most of the conditional expressions were inelegantly formed with redundant Booleans, abuse of operators, and so on.

if ($ticketAmount < 1000) $canProcess = true;
if ($canProcess)
  if ($avaiableCredit >= $ticketAmount)
    $canProcess = true;
    $canProcess = false;
if ($hasOverride) $canProcess = true;

if ($canProcess) ProcessTransaction($ticketId)
else RejectTransaction($ticketId);

Naturally, he decided to talk to the new guy about it, explaining that the above code could be simplified with an OR, an AND, and no confusing $canProcess variable. His workmate shook his head, replying with "Yes, that may be so, but you don't want to build your logic based on the way PHP implements those."

Miguel is not so easily discouraged. "It's not just PHP. It's for everything," he pressed on despite receiving a blank stare, "Boolean logic? You know, the way to find truth."

He gave up when Rene Descartes Jr. replied, "Truth is how you define it."

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!