I was working on a project that included complex logic logic. This complexity made the code very efficient, but unfortunately it is difficult to read.
So, we laid the logic, as shown below, which simplified the viewing of groups within compound statements, and also allowed us to add comments to parts of the logic.
(This code is not real code from the project, the real logic was more complex)
if (
angle.angle < kQuiteLow
&& (
previousAngle.angle > kQuiteHigh
|| previousAngle.time == kUnknownTime
)
&& pairedAngle.angle < kQuiteLow
&& (
previousPairedAngle.angle > kQuiteHigh
|| previousPairedAngle.time == kUnknownTime
)
)
Have you ever seen this elsewhere?
Are there any conventions or guidelines for style guides on how to lay out very complex logic?
source
share