Why we should take care about clean-code?
With the publication of the sap-styleguides, sustainable development or clean-code as it is called by Robert C.Martin becomes more and more popular in the SAP-developer-community.
Although this topic brings a lot of benefits, it was neglected for many years and often is still neglected in many SAP-development-projects.
Because of these reasons, i want to emphasize the benefits of sustainable development in this blog-post.
The aims of sustainable development
The most important aims are defined in the twelve principles of the Agile Manifesto. In the following list you can find some of these principles:
- Our highest priority is to satisfy the customer
through early and continuous delivery
of valuable software.
- Welcome changing requirements, even late in
development. Agile processes harness change for
the customer’s competitive advantage.
- Deliver working software frequently, from a
couple of weeks to a couple of months, with a
preference to the shorter timescale.
- Business people and developers must work
together daily throughout the project.
- Continuous attention to technical excellence
and good design enhances agility.
- Simplicity–the art of maximizing the amount
of work not done–is essential.
- At regular intervals, the team reflects on how
to become more effective, then tunes and adjusts
its behavior accordingly.
Meet the expectations of your customers
As business operations are more and more supported by software, more and more customers and business-owners expect implicitly:
- absence of issues or bugs,
- adaptability to new requirements,
- no unwanted break in existing behavior, when using a new release
As mention in the last section, one aim of sustainable development is to meet these expectations.
Therefore a lot of design-principles and workflows were written done. The website https://clean-code-developer.com has collected many of them.
Reduce technical debts
At the beginning of this section, i want to introduce the term technial debt. Technical debt is the collective name for:
- issues, which are difficult to reproduce, to solve or make behavior-changes of the existing code-base hardly possible,
- software-design, which easily causes negative or unexpected impacts after changes in the code-base.
Technical debts can be compared to monetary debts. Monetary debts make investments quickly possible. Same for technical debts. Projects can be quickly brought into production, if technical debts are not considered.
On the other hand the debts and the taxes must be payed off. The taxes for technical debts can be seen in the workarounds, which need to be continuously created for certain issues, and the huge amount of time spend on fixing bugs, that are difficult to trace back.
As you may expect, sustainable development means keeping technical debts on an low level or reduce them and enable with this continuous improvement processes.
Makes development painless for us and the next developer-generation
Sustainable development can preserve you from messy code-bases and from software-decline. Maintaining a messy or declined code-base is often a pain:
- negative impacts after changes are hard to find with tests,
- developers are often afraid touching the “running system”,
- the business-owners may start complaining about bugs,
- reading and understanding the code-base is a difficult task.
With sustainability, it’s getting painless:
- sustainable development means code-bases optimized for reading and traceability. In an clean-code-base you should easily find out what is going on.
- Clean-code makes automatic test-execution with a high coverage possible. Automatic test-execution can localize bugs and negative impacts more reliable than manual test-execution.
- As mention before, you meet the explicit and the implicit expectations of your customers.
The website https://clean-code-developer.com give you a short guide how to getting started with clean-code.
Most of the tools mention here are installed by default or can be installed on every new SAP-System:
- Version-Control: is build-in, an alternative is abapGit
- Automatized Integration Tests: can be done with ECATT
- Reviews: Can be done in principle with the Version-Control-Tool. Pull-Requests on GitHub or Merge-Requests on GitLab are providing extra functionality for reviews. Other options, which can be used directly in the SAP-system, are the diff-view from abapGit or Lars Hvam’s open-source-project abapOpenReview.
- Automatized Unit Tests: can be done with ABAP unit
- Mockups (Testdummies): can be created with the Test-Double-Framework
- Code-Coverage-Analyzer: SAP called their tool Coverage-Analyzer
Read, Read, Read
As the clean-code-developer-initiative mention in the orange grade, reading and further education is an important task for clean-code-developers. As SAP continuously deliviers new technologies to support sustainable development, we can take full advantage of clean-code, if we know how to deal with these technologies. Even though the procedurally-paradigm (reports, function-groups) doesn’t make clean-code-development impossible, new paradigms like ABAP-OO or code-push-down with ABAP-CDS make things easier and clearer to implement and new workflows like unit-tests with ABAP unit are creating safety belts for code-refactorings.
Reading-recommendations for newbies and experienced developers:
- the book Qualitätsmanagement in der ABAP-Entwicklung (german-version),
- the repository SAP Code Style Guides.
Fell free to contribute new items to this list.
Not just for agile projects
Even so many aims of sustainable development were formulated in the Agile Manifesto, sustainable
development is not only applicable in agile projects. Waterfall projects as well as agile projects can benefit from sustainable development.
nice, I'd probably suggest to use Pull/Merge requests on GitHub/GitLab for code reviews, but feel free to take abapOpenReview for a spin, but its not really maintained. See https://blogs.sap.com/2018/03/23/abap-code-reviews-with-abapgit/
There is also https://github.com/larshp/abapOpenChecks and https://github.com/abaplint/abaplint which can be used to check some of the style automatically.
I didn't thought of Pull/Merge requests. But they have some really good options discussion changes. So i added them to the review-section.
I’ve been a big fan of Clean Code for years. Every ABAP developer should know and consider the Clean Code Guidelines.
I would like to add the following:
Thank you for your comment. I added these points to the section "Getting Started"
This is a blog that is an interesting read after reading your blog.