I worked on a project which involved complex boolean logic. This complexity made the code very efficient, but unfortunately hard to read.
So we laid the logic out as below, which made it easier to see the groups within the compound statements, and also made it possible to add comments to parts of the logic.
(This code isn't real code from the project, the real logic was more complex)
if (
//comments here!
angle.angle < kQuiteLow
&& (
previousAngle.angle > kQuiteHigh
|| previousAngle.time == kUnknownTime
)
//comments in here too!
&& pairedAngle.angle < kQuiteLow
&& (
//and here
previousPairedAngle.angle > kQuiteHigh
|| previousPairedAngle.time == kUnknownTime
)
)
Have you ever seen this done anywhere else?
Are there any conventions or style guide recommendations on how to lay out very complex boolean logic?