How to create a Class in ABAP 00 – 6 Steps to start
This is not so much about which tool to use (AdT, SE24, VS-Code (is that a thing?)…) but more about what steps I take, when I want to program something (=> create a class).
And how I added more steps to the process while gaining more experience with OO.
(And: I think this is not even about ABAP…)
So it used to be just this:
1. Create the class.
2. Give it one public method.
But lately I added:
3. Create an interface.
4. Move the method to interface.
(Why have an interface? Because:
a. Its right thing to do (OO theory)
b. It helps me think about what is public and what not.
c. It helps with UnitTesting (Mocking) )
Also, I like to be able to start with unit tests right from the start (TDD maybe) so:
5. create test class. (using an adt template)
6. Add Interface and Class to testclass in setup, so the cut instance is created.
Now code away! 🙂
Do you have a similar list? (written down, or in your mind)
Care to share?
Am I missing something?
Edit: Here I show how I take those steps with an example: https://blogs.sap.com/2022/03/02/how-to-create-a-class-in-abap-00-example-code-with-little-typing.-adt-is-great/