Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
ennowulff
Active Contributor
Testing - coding - thinking - eating.

The Inwerken-ABAP Code Retreat took place in Isernhagen (Hanover, Germany) on November 22nd 2023. On an ABAP Code Retreat - founded in 2016 by majcon and christian.drumm - you will code together with other developers. The main task is to show how test driven development works. For this purpose the organizers choose a fairly common programming task like Game of Life or Bowling Kata.

This time my colleague maic.haubitz and I chose the programming task "Mars rover".


Enno and Maic



Mars Rover


The International space exploration network (German: INternationale Weltraum ERKundungs Netzwerk - INWERKN) had to program a mars rover which sould be controlled by some simple command sequence like: F10RF5LF3

The meaning of the commands is:

  • F = Forward

  • R = rotate right

  • L = rotate left


A command can be followed by a number that describes how many times the command must be executed. Example: F10 means "Go forward 10 steps"

Although this task seems to be quite easy, there are some pitfalls which need to be discussed or where you have to talk to the "client". There are several rounds with a different focus on the programming method. At least it is important how to proceed to produce testable code. Doing is the best way to learn and discuss with others.


Maic explaining things



Why Test Driven Development?


TDD - short for Test Driven Development - is a programming technique where you build your application by starting with defining the expectation of what the source code should do. You start by calling a method (that has no implementation yet) with some input parameters and gving the expected result. You do this with all reasonable test caes that you might think of. After having defined the test cases, you will start to implement the method. Your aim of course is to fulfill all given expectations.

Writing test cases is not as easy as it might sound, because you need to know the edge cases. If you test a function that adds two numbers, then it is useless to test hundreds of simple positive numbers. It is more interesting to test negative numbers, veeeery big numbers and so on. Depending on the input type you might also have to test if the input is a valid number.

This procedure makes sure that you have to think about all requirements in detail. The developer then exactly knows what input parameters might be used and what the output should be.

Is Test Driven Development the holy grail of programming?


In my opinion TDD is one method to get better coding. But it is not always and everywhere a no brainer. My reservation about TDD is, that you need to start with a quite detailed plan/ interface of your code. The used interfaces often changes as the application gets more complicated. Therefore you might refactor at an early time of the project. This also means that all already defined test cases need to be refactored.

Another point is, that TDD-advocates might want to have a 100% test coverage, where I think that it is not always possible and not always reasonable.

My favorite way is to build a prototype to make sure that all things work as suggested and to get a fast discussable result. After all that it is also possible to write test cases.

At least these are great things to discuss. Knowing the TDD technique definitely is a must-have skill for programmers. So if you do not know this technique or have not expreienced it in real life, then I highly recommend to train it. ABAP Code Retreats are really a great way to learning TDD.

Watch out in the SAP Community for ABAP Code Retreat events nearby.Unfortunately the ABAP Code Retreats are not listed in the SAP Community Events page... If anyone knows if there is a central page, please let me know.

~Enno
4 Comments
Michael_Keller
Active Contributor
Nice review and nice abbreviation: INWERKN ๐Ÿ˜‰

Regarding TDD: I agree with you and I always like to have a prototype first. This activates the discussion more quickly and shows feasibility. The "really" detailed plan is most of the time a real problem because a lot of things are done without an overall concept.
clean_coder2
Explorer

TDD is good practice, but in my opinion it is more important that there are (unit) tests, which approach is used to create the tests is secondary. 100% test coverage is not something to aim for, it's neither feasible nor useful. It should also be taken into account that the tests also cause maintenance effort.

ennowulff
Active Contributor
Thanks for your comment, keller.m

Yes, there are some weird coincidences in this world... ๐Ÿ˜˜๐Ÿ˜„

Good to know that there is another prototype fan! ๐Ÿ˜Ž
ennowulff
Active Contributor
0 Kudos
Thanks for your reply clean_coder2

There are persons who would like to haver 100% test coverage... I also don't think that this should be achieved by all means.

Having unit tests will result in more maintenance effort. Therefore you have less testing issues and a more robust program. Unfortunately this will often not be seen, because you just see the cost when creating the application โ€’ the maintenance costs will not be tracked...
Labels in this area