My sort of fun activitiy: Exercism for ABAP
The blog post about Abap on Exercism published by Lars Hvam couldn’t have come at a better time for me as I had a week off from work shortly afterwards! This gave me ample time to explore this new and rather intriguing offering which the team introduced in a YouTube livestream on April 1. If – like me – you’ve never heard of Exercism before, watching the 1 hour video is time well-spent to get an idea of what it is and how it works – not to mention the amount of work put into it to make it available by (at least) Lars, DJ Adams, Mike Pokraka, Marc Bernard, Marian Zeis, Thomas Jung and Rich Heilman.
After reading Lars’ blog post and watching the live-stream, I quickly created an account on Exercism and started to familiarize myself with the platform and how it works. As of right now, there are 24 ABAP exercises available, most of which are categorized as “easy”.
For each of these exercises, you’ll get a description of what should be programmed and you can then get started right away in the browser to tackle one of them in the built-in editor (or install Exercism locally). You don’t have to start from scratch but instead get the bare-bones class definition and methods as a starting point.
Instead of executing the class, you run the provided test cases to find out if your code works. You can do this even before adding some code yourself to get a better idea of what is expected. Not too surprisingly, most tests will then fail but some might already work, perhaps simply because they expect “0” or “space” as a result. For each of the failed tests, you’ll see the expected and the actual result which work as pointer of what you might need to tweak.
Once your code passes all the tests, you can publish your solution for others to take a look at and you also get access to the community solutions already out there which you can compare with your own solution. If you don’t quite get why something for example works and something else you tried didn’t work as expected, you can also request mentoring to initiate a discussion about your solution with one of the volunteer mentors.
It can be surprisingly tricky to get the syntax right for the needed (and often even rather simple) ABAP statements without code-completion or syntax checks readily available in the GUI or ADT. This made me realize just how spoiled we are when working within an SAP-system on ABAP code as I had to refer to the ABAP online documentation more than once to get the syntax right because I didn’t have a system readily available when I first tackled some of the exercises.
Not yet being well-versed with the (actually not so) new ABAP syntax available since NW 7.40, I often came up with a solution which passed all the tests but was much more involved than it needed to be with the “new” syntax. This is where the community solutions can provide quite a neat learning experience by comparing my own to others’ solutions and trying out some of the other options in a 2nd or 3rd iteration.
Something else I like about the exercises are the test cases provided for each of them. These provide simple to follow and understand examples of how to go about coding a local test class, something which I’m sure will come in handy later when an opportunity presents itself to make use of test cases myself.
I did run into some issues I couldn’t really make heads or tails of where I was wondering what I was missing and/or getting wrong (always a distinct possibility!). Following Lars’ suggestion in response to my comment on his blog post, I started to create issues in the related Github repository whenever I hit a roadblock (and was fairly certain that it wasn’t a “PEBKAC“!) and these were then tackled very quickly by him and Mike Pokraka.
Up to now, I’ve worked through 8 exercises and hope to tackle more as time allows.
And, as hard to believe as it is, there is no actual SAP/ABAP system behind all of this and I don’t even dare imagine how many hours the team spent to create these ABAP exercises with something called “abaplint” and “transpiler” in the background.
Big Thanks to everybody involved for making this available!