styleguides
styleguides copied to clipboard
SAP Dictionary Style Guides versus SAP Code Style Guides
I came across the following issue: https://github.com/SAP/styleguides/issues/171 where it discusses the database and the use of date time, which I found interesting. I worked with a developer who fancied using UTC timestamps without any reason, but this was disastrous for querying on from a Dynpro Report, requiring mapping and additional performance loss.
As I use CleanABAP to convince programmers of certain things, I'd like to do the same to dictionary objects. @HrFlorianHoffmann asked the question if CleanABAP is the right place for this, but I'd like to discuss exactly that to see what the community thinks, before creating a pull request.
After all, it's called 'CleanABAP', code and dictionary are tightly intertwined, especially now that we'll be pushing more and more code matters down to the database.
So proposal to add Dictionary topic, some thoughts:
- Structures and Tables: If structure or table contains more than 100 fields, consider creating logical structures per domain and include them in the main structure or table. E.g. a PAYMENT table can contain an include for: Payer, Payee and Payment details.
- Tables: Use DATE and/or TIME field for straight forward matters. Only use UTC for specific cases, do note that often UTC is very abap stack sensitive, e.g. in Gateway/OData this is not always supported
- CDS and the use of Performance related annotations ( https://blogs.sap.com/2020/02/06/cds-view-performance-annotation-for-cds-view-performance/ )
- CDS naming conventions
- Customer Includes and the use of 'ZZ' or 'YY' to avoid issues at upgrades
Or is a 'SAP Dictionary Style Guides' in order? As I see the header of CleanABAP page is 'SAP Code Style Guides'
Good idea. Unfortunately, I am only aware of several internal DDic and/or CDS style guides. Nothing that could be published straight away...
@xtough I'm still finding it a difficult, one could say this belongs more in best practice guidelines (e.g. DSAG one) Are we able to clearly define CDS/DDIC things relating to 'Cleancode' without going to implementation best practices? Or is it acceptable to also include implementation best practices here?
adding @KlausHaeuptleSAP and @HrFlorianHoffmann : any opinion?
The idea of a Clean CDS existed some time ago, but did not get a lot of traction. Still it would be highly relevant for ABAP and Non-ABAP. Somehow CDS is a language on its own and has implementations for different technology stacks.
One question is where to store such recommendations? Alternatives are:
- In the Clean ABAP file
- In a new Clean CDS file. Could also be a Clean ABAP CDS file if there are too many differences between the different CDS implementations.
Additionally we would need core owners/reviewers from the CDS language development - the language is still in its early stage and evolving a lot).
Another question is how to apply Clean Code principles to CDS and how to balance it with performance.
I'm all in favour of a CDS guide, there's a lot of bad CDS being written out there. You'd be amazed how hard it is to convince people not to use the DDIC field names like auart
in CDS views. I think it could help if we even just start out with these kind of basics.
I also think the ABAP guide is getting a bit big so putting it into a separate section may be easier to manage. CDS is also a bit of a specialist field you can get quite deep into, and it's quite feasible to build Fiori apps and Gateway services based on CDS without writing a single line of ABAP.
FYI, coincidentally, blogpost and comments going in regards to date, time and timestamps: https://blogs.sap.com/2021/05/16/time-stamps-in-abap/comment-page-1/#comment-574580
- CDS and the use of Performance related annotations ( https://blogs.sap.com/2020/02/06/cds-view-performance-annotation-for-cds-view-performance/ )
About that blog post : I don't think that these annotations improve performance. It is just information that can be helpful to a developper that wants to use this CDS view. I might be wrong but that's what I find out after doing some research when I found this blog post.
But yes, CDS view performance guidelines should exist (and I think that it is SAP job to initiate it). As @xtough said, SAP has internal documentation about CDS, I don't understand why they keep it secret (or maybe I do know but that is not a good reason).