ABAP is an awesome programming language, and there are often many ways to get to the same end result. But as humans, we tend to stick to habits and do the same things in the same ways as always unless we consciously tries new ways. Hopefully these ways are good, but in order to improve and evaluate we need to be challenged or challenge our ideas.
One way to try new things, to experiment, and to expand and learn, is to write one or a couple of solutions to a non-work-related programming challenge. No matter if you’re a novice to ABAP and programming or if you’ve got 30 years under your belt, you could either try to solve it at all, or in some new and obscure way.
Doing it non-work-related might release us from the constraints of requirements, guidelines, habits and routines. But hopefully it will give a positive ROI on our knowledge and will hopefully bring back value to ourselves and our employers and customers.
Sharing is caring
Sharing the solutions could also bring value and knowledge to fellow developers. I started a repository where I intend to collect puzzles and create demo example solutions using the various aspects of the ABAP language, and I welcome you all to join! Either by sharing puzzles or challenges that you deem fit here, or by proposing alternate solutions or comments.
The link to the repository is at the end of this post but if you would like to try it out yourselves first, without being influenced by other solutions, wait a bit until clicking that link.
This one is a very simple one and can be done in various ways and searching on the forum here reveals a couple of blog posts talking about it already. (For instance The SAP Technical ABAP Interview Question You Might Have Never Heard Of from as late as august of last year). I think this is bigger outside of the ABAP world that inside.
Fizz Buzz is allegedly originally a childrens game to practice division, with some simple rules.
The first player starts by saying the number 1 and players then take turn counting upwards one number at a time, but:
- If a number is evenly divisable by 3, the player instead says ‘Fuzz’
- If a number is evenly divisable by 5, the player instead says ‘Buzz’
- If a number is evenly divisable by both 3 and 5, the player says ‘FizzBuzz’
So, it would start like this:
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz
The challenge here is to implement this in ABAP to output the first 100 rounds of the FizzBuzz game.
And then there was the repository
I will get back to you with more puzzles in the future if you think you’d enjoy that. The central place for them will be this repository on GitHub. Currently there is only FizzBuzz with a couple of example solutions with various degrees of ‘goodness’. 😁
And please share your interesting solutions here in the comments or in the repository. I will gladly have additional alternate solutions added to the fizzbuzz class there (with explanations if needed). Either by a pull request, or by asking me to do it.