14.01.2020 Views

ABAP_to_the_Future

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1

ABAP in Eclipse

not need your comment any more—but that’sa minor nitpick. It’s easy enough to

change the newly created me thod, and certainly this process involves a lot less

effort than manually creating the implementation and definition.

Furthermore, it’s likely that in higher releases you will be able to tell Eclipse to go

hunting for identical blocks and replace them all with calls to your new method

(i.e., in the preceding example all three IF/THEN/ELSE constructs would have been

replaced with method calls).

1.2.5 Deleting Unused Variables

A common programming mantra is “First make it work—then make it good.” Following

this principle means messing around until you get whatever it is working

and then clearing up the mess you made while experimenting.

Traditionally, when progra mming inside the SAP GUI using SE80 or a related

transaction, the standard extended program check (SLIN) is good at helping with

this; you are given a list of variables that have been declared but never get used.

This happens because you needed the variables at some point while the program

was evolving but then deleted the code that used them because you no longer

needed that code. Unused variables are bad, because they take up some memory

at runtime for no purpose and also be cause they clutter the code, making it

harder to read, which is a cardinal sin.

Say that as a part of your monster project you’re called upon to write a program

to perform the most complicated mathematic al operation in the world. It takes

months of sweat and tears, but at the end you have a program that comes up with

the correct result; it looks like Listing 1.10.

METHOD main.

* Local Variables

DATA: ld_use_this TYPE i,

ld_also_this TYPE i,

ld_result TYPE i,

ld_not_used TYPE i,

ld_not_used2 TYPE i,

ld_not_used3 TYPE i.

ld_use_this = 1.

ld_also_this = 1.

58

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!