My job requires me to work in RPG, an old, old language. Worse yet I cannot use the free keyword because of our pre-processor, and I don't see that changing for some time.
With that in mind, I show you what I have learned when working with conditionals (specifically if
).
Let's first assume that lowercase are boolean expressions and that uppercase are sets of statements and expressions (i.e., code instructions). Next I present some snippets, following a demonstration on how to simplify them.
Note: Ignore the brackets. I only use then to make clear where code breaks.
Case 1
Simplification:
Case 2
Yes, I do find many of these:
Simplification:
Case 3
Intermediate step:
Simplification:
To some people this can seem quite obvious, but I find that most people don't bother to apply these rules, which gives readability a punch in the face.
No comments :
Post a Comment