@foessleitnerj Refactoring … with ADT
@foessleitnerj
Refactoring
… with ADT
@foessleitnerjRefactoring with ADT
“The process of changing a software system in such a way that it does not alter the external behaviour of the code, yet improves its internal structure.”
What is Refactoring?
Martin Fowler, Refactoring 1999
https://www.refactoring.com
@foessleitnerjRefactoring with ADT
ISBN: 978-0201485677
Refactoring, by Martin Fowler
@foessleitnerjRefactoring with ADT
Test Development
Refactoring
• Add a Test Make it work
Make it clean
Refactoring & TDD
@foessleitnerjRefactoring with ADT
TDD RefactoringRefactoring
?Refactoring
?Refactoring
Workflow of Refactoring
?Refactoring
@foessleitnerjRefactoring with ADT
Workflow of Refactoring
Just bad code!Litter-PickupRefactoring
?Refactoring
?Refactoring
TDD RefactoringRefactoring
@foessleitnerjRefactoring with ADT
Workflow of Refactoring
I don‘tunderstand
Litter-PickupRefactoring
ComprehensionRefactoring
?Refactoring
TDD RefactoringRefactoring
@foessleitnerjRefactoring with ADT
Workflow of Refactoring
We shouldhave done itthis way
Litter-PickupRefactoring
ComprehensionRefactoring
PreparatoryRefactoring
TDD RefactoringRefactoring
@foessleitnerjRefactoring with ADT
Code Smells „stinkt“ (© Robert C. Martin)
• Examples
• Duplicates
• Long methods
• Big classes
• Big case statements
• Bad names
• Misleading comments
• …
@foessleitnerjRefactoring with ADT
Example 1: Misleading comments
* get all fields of BUT000
SELECT PARTNER, NAME1 FROM BUT000 INTO …
* exit on error & FLAG <> ‘X‘
IF SY-SUBRC > 0 AND FLAG = ABAP_TRUE.
EXIT.
ENDIF.
@foessleitnerjRefactoring with ADT
Example 2: Method name
•What happens in the method• LR_DATE->ADD( 5 )
•Better• LR_DATE->ADDDAYSTO( 5 )
• LR_DATE->INCREASEBYDAYS( 5 )
@foessleitnerjRefactoring with ADT
https://www.refactoring.com
@foessleitnerjRefactoring with ADT
Code Quality
Clean Code
Profssionalism
Right Thing
Why Refactor?
@foessleitnerjRefactoring with ADT
Why Refactor?
Economy
@foessleitnerjRefactoring with ADT
“We are doing this, to be able to deliver more functionality more quickly.”
Martin Fowler, a pionier of the agile software development
Why Refactor?
@foessleitnerjRefactoring with ADT
https://twitter.com/foessleitnerj
https://www.linkedin.com/in/johann-fößleitner-a9851b2a
https://www.xing.com/profile/johann_foessleitner
Thank you!https://twitter.com/domibiglsap
https://www.linkedin.com/in/dominik-bigl-9b98b68b
https://www.xing.com/profile/dominik_bigl