styleguides icon indicating copy to clipboard operation
styleguides copied to clipboard

Drop namespace prefixes - /clean/ /dirty/ etc.

Open pokrakam opened this issue 5 years ago • 4 comments

The examples this guide often use prefixes /clean/ and /dirty/ to indicate good and bad examples.

Personally I'm not a fan of their use. To me they are actually an anti-pattern, as they add words and symbols to the examples that decrease readability without adding new information. It's already clear from the context and/or comments what type of example it is, so I find them redundant. Use of this type of convention also make it more difficult to express finer nuances as you can with comments, such as "use only when necessary", or "inferior".

Take for example, the Interface Pattern sample code:

" inferior pattern
INTERFACE /dirty/message_severity.
  CONSTANTS:
    warning TYPE symsgty VALUE 'W',
    error   TYPE symsgty VALUE 'E'.
ENDINTERFACE.

I would prefer to see this written without /dirty/:

" inferior pattern
INTERFACE message_severity.
  CONSTANTS:
    warning TYPE symsgty VALUE 'W',
    error   TYPE symsgty VALUE 'E'.
ENDINTERFACE.

What do people think?

pokrakam avatar May 07 '19 10:05 pokrakam

No objections. :-)

HrFlorianHoffmann avatar May 07 '19 15:05 HrFlorianHoffmann

Apart from SAP, everyone must prefix or use the Y / Z name space. So without the prefixes, the examples look less real word to me.

nomssi avatar May 08 '19 09:05 nomssi

@nomssi , good point, but this is understandable as it started out for internal use by people who aren't bound by those restrictions.

Do you mean less real world than with the /clean/ prefix? I can also agree it looks a bit odd because we're all used to having classes prefixed with (z)cl_, so my brain looks for cl_message_severity. But that's being discouraged by this very guide too.

The ABAP reference books and ABAP documentation don't use 'Z', so to me it still looks natural. And it is valid for all non-dictionary objects, us mortals can write this in reports and local classes :-)

The style options would be:

  1. CLASS message_severity.
  2. CLASS zmessage_severity.
  3. CLASS cl_message_severity.
  4. CLASS zcl_message_severity.
  5. CLASS /clean/message_severity.

3 and 4 are closest to what we're used to, but are discouraged. I'm not too fussed between 1 and 2, but 1 is that tiny bit simpler and emphasises the 'use descriptive names' point a little bit better.

pokrakam avatar May 08 '19 10:05 pokrakam

ok, the hungarian notian is something I hate since I joined the language. So clean ABAP says noone need it and I'm absolutely with it. So in my opinion we should go for number 2.

f4abap avatar Jul 14 '19 19:07 f4abap