Introduction
Coming from a computer science background and having learnt ABAP on the job in a SAP consultancy, I always wondered why there are so restrictive naming-conventions and why every customer has their own custom ones, each apparently trying to trump the other with even more detailed naming-conventions for every little technical possibility... To me it seems to be a SAP-speciality that has vanished everywhere else (or so it seems ... hello cobol legacy applications, hello hungarian notation)
Having read this interesting uwe.schieferstein/blog/2009/08/31/nomen-est-omen--abap-naming-conventions a while ago and having to tackle a big custom code-base ourselves (with our own inevitable hardcore-detailed naming conventions and our own fair share of technical debt ...) we discussed what to focus on in the future.
Goals: Simple, short & concise code conventions that ease development and make the code easier to read.
After all, you as a developer are spending about 70% of your time reading & analysing existing code. You want that code to be short and readable. And you don't want to constantly lookup naming conventions, do you?
How much code do you fully understand from top to bottom? Can you analyse & memorize only 100 lines of unbroken, unknown code and estimate the implication of new changes? I don't. I feel big relief if that code is broken up into as many form-routines (functions, methods, whatever) as possible: We dearly want Seperation of Concerns.
Decisions
Some Rules derived from these decisions:
TL/DR: This leads to the following inevitable naming-convention-matrix:
Prefix | Comment | |
---|---|---|
Locals | NONE | |
Globals | G_ | |
Field-Symbols | <NONE> | Really ugly: global Field-Symbols: <G_XXX> |
Atttributes | NONE | Use "me->attribute" to distinguish from locals if necessary |
Constants | CO_ | No distinction local vs. global (Omit prefix in constant-interfaces) |
Types | TY_ | No distinction local vs. global |
Form Using | I_ | Concentrate: Using = Importing/Input, no need to distinguish |
Form Changing | C_ | |
FM Importing | I_ | Try by reference |
FM Exporting | E_ | Try by reference |
FM Changing | C_ | Try to avoid |
FM Table | T_ | Avoid! |
Method Importing | I_ | Try by reference |
Method Returning | R_ | |
Method Exporting | E_ | Try to avoid |
Method Changing | C_ | Try to avoid |
Select-Options | S_ | |
Parameters | P_ |
This table is hopefully concise enough, we actually printed it on 1 DinA5, instead of the former 2 DinA4 pages.
Before starting the eagerly awaited flame war, please consider that these conventions follow those described in the book Official ABAP Programming Guidelines. of Horst Keller, Wolf Hagen Thümmel - by SAP PRESS (p. 208ff). Even if the internal SAP conventions really hurt my eyes and every SAP development team seems to use their own even more cumbersome conventions, Thank you Horst Keller for these guidelines.
No conclusion yet, we just started with these conventions and still figure out how to transform the existing code-base in a pragmatic approach...
Tools
Code-Inspector Test based on CL_CI_TEST_SCAN to limit the allowed Lines of code (Will release that soon...)
We are using smartDevelop but still need to figure out a good transformation-strategy.
Thank you for your attention, any comments appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
3 | |
3 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |