SAP / styleguides

This repository provides SAP style guides for coding and coding-related topics.
Other
1.68k stars 446 forks source link

Clarify use of static method reference #210

Closed pokrakam closed 3 years ago

pokrakam commented 3 years ago

I think the style guide should contain some guidance on the use of static method calls, especially within a class. My opinion on the ways to call a static method are:

lo_obj->static( ).     "looks like instance, avoid
static( ).             "class calling its own static method, use only if it's obvious
cl_foobar=>static( ).  "Safe and unambiguous

In the book chapter 4.1.1 does offer some guidance, suggesting: Make the fact that you’re calling a static method clear by always qualifying the method call with the class name.

Also see discussion at https://github.com/abaplint/abaplint/issues/1952

On a general note, the book is great but I believe the core guidelines elements (grey boxes) should be part of the style guides in order to foster wider adoption and none of them should be exclusive to the book. For most part this seems to be the case and I hope this was just an omission. The book is an excellent educational resource beyond the style guides with all its practical examples and deep dives into the rationale behind the guides.

HrFlorianHoffmann commented 3 years ago

@pokrakam That was indeed an omission. Our plan was, and still is, that this repository is the leading artifact. The book should provide additional content that helps understanding, but it shouldn't contain exclusive guidelines.