This post was originally posted on SDN on 07-10-2020. I decided to keep some of my posts here too.
Don’t focus on code semantics, but the visual representation. It is just dummy example, it’s all about formatting.
The first examples, following Clean ABAP preferred rules: and with helper variables: Now applying refactoring – Alt+Shift+R in Eclipse, some names changed: the second with helper variables after name changes: Now different style examples with line break and incremental indentation: with helper variables: Applying refactoring, names changed: and the second version with helper variables refactored: The last two images shows why I personally prefer using incremental indentation – no messed up code after renaming. Both styles are readable for me but this the second one without so strict alignment is refactoring-friendly, which is a very important thing for constant improvement of code and naming things correctly. I don’t want to manually correct main code + unit test code + dependent code after each name change (and be sure that everyone in a team remember to “fix” code after his or her refactoring changes). This heavily right-aligned code is also hard to read on smaller screens in editors or webpages like version control systems.
Speaking of version control – here are diffs for the Clean ABAP preferred rule, after refactoring I have aligned all things again.
There is also a discussion on this topic in Clean ABAP repo: