<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ABAP Unit - using local class for dependencies in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-unit-using-local-class-for-dependencies/m-p/12421948#M1997308</link>
    <description>&lt;P&gt;Howdy, folks!&lt;/P&gt;
  &lt;P&gt;I'm beginning to work "seriously" with ABAP Units and, in a some weird way, TDD. I've read the impressive e-bite from &lt;SPAN class="mention-scrubbed"&gt;bfeeb8ed7fa64a7d95efc21f74a8c135&lt;/SPAN&gt; called "Refactoring Legacy ABAP code" (a must read if you are into these things), and I've almost understood the basics.&lt;/P&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;Maybe because I'm a lazy b...rd, I build my first legacy-killer class this way:&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;one class for each FORM in the INCLUDE to remove (it's a heavy EXIT-type include), with NO factory method&lt;/LI&gt;
   &lt;LI&gt;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&lt;/LI&gt;
   &lt;LI&gt;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&lt;/LI&gt;
   &lt;LI&gt;and a main test class (I don't think I will need more than one)&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;Now, if you have understood my explanation, I'm sure you are asking yourselves&lt;/P&gt;
  &lt;P&gt;WHAT IS WRONG WITH THIS GUY?&lt;/P&gt;
  &lt;P&gt;And that's just my question: &lt;STRONG&gt;what's wrong with my approach?&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 31 May 2021 14:07:18 GMT</pubDate>
    <dc:creator>VXLozano</dc:creator>
    <dc:date>2021-05-31T14:07:18Z</dc:date>
    <item>
      <title>ABAP Unit - using local class for dependencies</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-unit-using-local-class-for-dependencies/m-p/12421948#M1997308</link>
      <description>&lt;P&gt;Howdy, folks!&lt;/P&gt;
  &lt;P&gt;I'm beginning to work "seriously" with ABAP Units and, in a some weird way, TDD. I've read the impressive e-bite from &lt;SPAN class="mention-scrubbed"&gt;bfeeb8ed7fa64a7d95efc21f74a8c135&lt;/SPAN&gt; called "Refactoring Legacy ABAP code" (a must read if you are into these things), and I've almost understood the basics.&lt;/P&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;Maybe because I'm a lazy b...rd, I build my first legacy-killer class this way:&lt;/P&gt;
  &lt;UL&gt;
   &lt;LI&gt;one class for each FORM in the INCLUDE to remove (it's a heavy EXIT-type include), with NO factory method&lt;/LI&gt;
   &lt;LI&gt;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&lt;/LI&gt;
   &lt;LI&gt;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&lt;/LI&gt;
   &lt;LI&gt;and a main test class (I don't think I will need more than one)&lt;/LI&gt;
  &lt;/UL&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;Now, if you have understood my explanation, I'm sure you are asking yourselves&lt;/P&gt;
  &lt;P&gt;WHAT IS WRONG WITH THIS GUY?&lt;/P&gt;
  &lt;P&gt;And that's just my question: &lt;STRONG&gt;what's wrong with my approach?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 May 2021 14:07:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-unit-using-local-class-for-dependencies/m-p/12421948#M1997308</guid>
      <dc:creator>VXLozano</dc:creator>
      <dc:date>2021-05-31T14:07:18Z</dc:date>
    </item>
  </channel>
</rss>

