Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP Unit - using local class for dependencies

VXLozano
Active Contributor
0 Likes
606

Howdy, folks!

I'm beginning to work "seriously" with ABAP Units and, in a some weird way, TDD. I've read the impressive e-bite from bfeeb8ed7fa64a7d95efc21f74a8c135 called "Refactoring Legacy ABAP code" (a must read if you are into these things), and I've almost understood the basics.

But I'm not sure if I can get that e-bite as a rule or just as a guideline, when referring to the objects structure.

Maybe because I'm a lazy b...rd, I build my first legacy-killer class this way:

  • one class for each FORM in the INCLUDE to remove (it's a heavy EXIT-type include), with NO factory method
  • within the class, I removed the dependencies by creating a LOCAL CLASS with its corresponding interface "ifdependenciesremover" where I put all the SELECTs and plan to put all user interactions
  • in the test class folder (I'm a lucky eclipse user) I created a local class "injector" to mock the main class during the tests
  • and a main test class (I don't think I will need more than one)

The main idea about this is to keep all those things as close as possible, not been accessible by foreig items. Obviously, if I detect that a dependency is used by more than a single class (been the only developer, I guess it will be easy to notice), I will create a global class ZCL_xxxx with a method for that dependency, and in the corresponding ifdependenciesremover method I will put a call to it.

The only drawback I see it's the coverage of my tests will be never the 100%, but because I know it, I just ignore the global bar and I just look at the main class one.

Now, if you have understood my explanation, I'm sure you are asking yourselves

WHAT IS WRONG WITH THIS GUY?

And that's just my question: what's wrong with my approach?

0 REPLIES 0