Todo Based Coding in ABAP

This article has been featured by SAP among March & April 2019 contributions.

https://blogs.sap.com/2019/05/16/featured-blog-contributors-march-april-2019/

Today, I would like to demonstrate a very simple but effective programming habit that I use in ABAP development: TODO based coding.

The idea is to plant TODO comments into the code (typically among multiple programs / classes) before actually starting to write / modify code. That enables us a few things:

  • Planning before coding
  • Simplifying large refactoring tasks
  • Figuring any semantic / functional gaps before modifying the code
  • Eliminating the risk of forgetting things
  • New programmers can take over incomplete programs

However, in order to make this technique effective, we need to make the compiler / IDE warn us if there are TODO’s left in the compiled code. Otherwise, incomplete code might to do production.

Looking at some other platforms;

  • Pycharm (Python IDE) shows #TODO comments as a separate list in the IDE
  • XCode (Swift IDE) evaluates #warning commands as compiler warnings and shows them every time you compile the code

As far as I know, ABAP lacks such a feature. The closest thing that I know is the task lists in Eclipse, but they are stored in the local machine; so a new programmer doesn’t see them at all.

My simple but effective solution is to use a fake pragma: ##TODO.

SAP doesn’t recognize this pragma, so every time I check or activate a code containing ##TODO. , SAP will show a warning. Eclipse or SE80, works in both.

Here is how a typical todo looks like:

##TODO.
" Complete ZCL_CLASS1=>METHOD1 first
 " call METHOD1 here
 " ensure that the returned value is OK
 " otherwise, raise an exception

Me & some members of my ABAP team are using this technique since a while, and we are happy with the results.

This approach can also be used when the architect and programmer are different people. The architect can create all the programs, classes, critical methods, interfaces, etc and fill them with ##TODO comments. After that, programmers can step in and start coding; clearing the architectural ##TODO ‘s.

I hope that this approach will benefit other fellow developers as well.

Türkçe bilen okurlar, bu makaleye ait SAP Inside Track Istanbul 2019 sunumumu burada izleyebilir.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s