At the company I work for, there has recently been a mandate that all ‘highly visibile’ boolean logic must be expressed in Disjunctive Normal Form.
So for instance (though the concept is language agnostic),
#if (defined(A) || defined( B )) || (defined(C) && defined(D))
had to be replaced with:
#if defined(A) || (defined(C) && defined(D)) || defined(B)
What is the motivation for mandating that code has to be expressed in this manner? What are the advantages?
The advantage is that expressing such logic in a canonical/normalized form everywhere within a codebase will (theoretically) make it easier for programmers to understand and maintain it.
Without such a rule, some programmers are apt try to “optimize” an expression in such a way that it becomes difficult for a maintainer to unravel it. Also, a common form makes it easier to compose new expressions if that becomes necessary.
(These advantages are debatable. As with any stylistic guideline, having a consistent rule to follow is more important than the choice of one rule over its alternatives.)