SlideShare a Scribd company logo
1 of 16
@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 Refactoring
Refactoring
?
Refactoring
?
Refactoring
Workflow of Refactoring
?
Refactoring
@foessleitnerjRefactoring with ADT
Workflow of Refactoring
Just bad code!Litter-Pickup
Refactoring
?
Refactoring
?
Refactoring
TDD Refactoring
Refactoring
@foessleitnerjRefactoring with ADT
Workflow of Refactoring
I don‘t
understand
Litter-Pickup
Refactoring
Comprehension
Refactoring
?
Refactoring
TDD Refactoring
Refactoring
@foessleitnerjRefactoring with ADT
Workflow of Refactoring
We should
have done it
this way
Litter-Pickup
Refactoring
Comprehension
Refactoring
Preparatory
Refactoring
TDD Refactoring
Refactoring
@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
johann.foessleitner@cadaxo.com
Thank you!
https://twitter.com/domibiglsap
https://www.linkedin.com/in/dominik-bigl-9b98b68b
https://www.xing.com/profile/dominik_bigl
dominik.bigl@cadaxo.com

More Related Content

Similar to ABAP CodeRetreat 20.5.2017 Vienna - Refactoring

Ips jtoow full seo cms presentation
Ips jtoow full seo cms presentationIps jtoow full seo cms presentation
Ips jtoow full seo cms presentation
snapkode
 
Refactoring, A First Example
Refactoring, A First ExampleRefactoring, A First Example
Refactoring, A First Example
Vorleak Chy
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in Refactoring
Chamnap Chhorn
 

Similar to ABAP CodeRetreat 20.5.2017 Vienna - Refactoring (20)

Refactoring
RefactoringRefactoring
Refactoring
 
The Power Of Refactoring (4developers Krakow)
The Power Of Refactoring (4developers Krakow)The Power Of Refactoring (4developers Krakow)
The Power Of Refactoring (4developers Krakow)
 
Ips jtoow full seo cms presentation
Ips jtoow full seo cms presentationIps jtoow full seo cms presentation
Ips jtoow full seo cms presentation
 
Refactoring, A First Example
Refactoring, A First ExampleRefactoring, A First Example
Refactoring, A First Example
 
The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)The Power Of Refactoring (PHPCon Italia)
The Power Of Refactoring (PHPCon Italia)
 
Python For Technical SEO | Women In Tech SEO Festival March 2020 | Ruth Everett
Python For Technical SEO | Women In Tech SEO Festival March 2020 | Ruth Everett Python For Technical SEO | Women In Tech SEO Festival March 2020 | Ruth Everett
Python For Technical SEO | Women In Tech SEO Festival March 2020 | Ruth Everett
 
A tour of React Native
A tour of React NativeA tour of React Native
A tour of React Native
 
Translating share point from beginning to ending
Translating share point from beginning to endingTranslating share point from beginning to ending
Translating share point from beginning to ending
 
Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016Test Driven Design - GDG DevFest Istanbul 2016
Test Driven Design - GDG DevFest Istanbul 2016
 
Test Driven Design
Test Driven DesignTest Driven Design
Test Driven Design
 
The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)The Power Of Refactoring (php|tek 09)
The Power Of Refactoring (php|tek 09)
 
When to refactor
When to refactorWhen to refactor
When to refactor
 
Principles in Refactoring
Principles in RefactoringPrinciples in Refactoring
Principles in Refactoring
 
The Power of Refactoring
The Power of RefactoringThe Power of Refactoring
The Power of Refactoring
 
WF 202 Advanced Workflow Solutions
WF 202 Advanced Workflow Solutions WF 202 Advanced Workflow Solutions
WF 202 Advanced Workflow Solutions
 
Refactoring to Testable Code
Refactoring to Testable CodeRefactoring to Testable Code
Refactoring to Testable Code
 
Tackling Python: What is it and How Can it Help with Technical SEO? | TechSEO...
Tackling Python: What is it and How Can it Help with Technical SEO? | TechSEO...Tackling Python: What is it and How Can it Help with Technical SEO? | TechSEO...
Tackling Python: What is it and How Can it Help with Technical SEO? | TechSEO...
 
The Power Of Refactoring (PHPNW)
The Power Of Refactoring (PHPNW)The Power Of Refactoring (PHPNW)
The Power Of Refactoring (PHPNW)
 
Tackling Python: How It Can Help With Technical SEO | Pint Sized Meetup Janua...
Tackling Python: How It Can Help With Technical SEO | Pint Sized Meetup Janua...Tackling Python: How It Can Help With Technical SEO | Pint Sized Meetup Janua...
Tackling Python: How It Can Help With Technical SEO | Pint Sized Meetup Janua...
 
Getting Started with Python and Machine Learning for SEO | BrightonSEO Octobe...
Getting Started with Python and Machine Learning for SEO | BrightonSEO Octobe...Getting Started with Python and Machine Learning for SEO | BrightonSEO Octobe...
Getting Started with Python and Machine Learning for SEO | BrightonSEO Octobe...
 

More from Cadaxo GmbH

Abap 7 02 new features - new string functions
Abap 7 02   new features - new string functionsAbap 7 02   new features - new string functions
Abap 7 02 new features - new string functions
Cadaxo GmbH
 

More from Cadaxo GmbH (20)

Webinar SAP/ABAP und Microsoft
Webinar  SAP/ABAP und MicrosoftWebinar  SAP/ABAP und Microsoft
Webinar SAP/ABAP und Microsoft
 
Webinar - ABAP Releasenotes 7.53/7.54
Webinar - ABAP Releasenotes 7.53/7.54Webinar - ABAP Releasenotes 7.53/7.54
Webinar - ABAP Releasenotes 7.53/7.54
 
Webinar ABAP Managed Database Procedures
Webinar ABAP Managed Database ProceduresWebinar ABAP Managed Database Procedures
Webinar ABAP Managed Database Procedures
 
Webinar - ABAP Development Tools
Webinar - ABAP Development ToolsWebinar - ABAP Development Tools
Webinar - ABAP Development Tools
 
Webinar - Entwurfsmuster in ABAP
Webinar - Entwurfsmuster in ABAPWebinar - Entwurfsmuster in ABAP
Webinar - Entwurfsmuster in ABAP
 
Webinar Modern ABAP
Webinar Modern ABAPWebinar Modern ABAP
Webinar Modern ABAP
 
Webinar ABAP 7.51 Releaseinformationen
Webinar ABAP 7.51 ReleaseinformationenWebinar ABAP 7.51 Releaseinformationen
Webinar ABAP 7.51 Releaseinformationen
 
Webinar - SAP Gateway
Webinar  - SAP GatewayWebinar  - SAP Gateway
Webinar - SAP Gateway
 
Webinar - ABAP CDS Views
Webinar - ABAP CDS ViewsWebinar - ABAP CDS Views
Webinar - ABAP CDS Views
 
SQL Cockpit 3.1 - Overview
SQL Cockpit 3.1 - OverviewSQL Cockpit 3.1 - Overview
SQL Cockpit 3.1 - Overview
 
Webinar - SAP BOPF
Webinar - SAP BOPFWebinar - SAP BOPF
Webinar - SAP BOPF
 
Webinar - ABAP 7.50 Releaseabhängige Änderungen
Webinar - ABAP 7.50 Releaseabhängige ÄnderungenWebinar - ABAP 7.50 Releaseabhängige Änderungen
Webinar - ABAP 7.50 Releaseabhängige Änderungen
 
TDD mit ABAP Units
TDD mit ABAP UnitsTDD mit ABAP Units
TDD mit ABAP Units
 
Clean code in ABAP
Clean code in ABAPClean code in ABAP
Clean code in ABAP
 
Webinar - Boost your ABAP
Webinar - Boost your ABAPWebinar - Boost your ABAP
Webinar - Boost your ABAP
 
SQL Cockpit - Releasenotes 3.0
SQL Cockpit - Releasenotes 3.0SQL Cockpit - Releasenotes 3.0
SQL Cockpit - Releasenotes 3.0
 
Webinar ABAP 7.40 sp5/sp8 Releaseinformationen
Webinar ABAP 7.40 sp5/sp8 ReleaseinformationenWebinar ABAP 7.40 sp5/sp8 Releaseinformationen
Webinar ABAP 7.40 sp5/sp8 Releaseinformationen
 
Prüfen Sie Ihre ABAP SQL Abfragen auf SAP HANA Tauglichkeit
Prüfen Sie Ihre ABAP SQL Abfragen auf SAP HANA TauglichkeitPrüfen Sie Ihre ABAP SQL Abfragen auf SAP HANA Tauglichkeit
Prüfen Sie Ihre ABAP SQL Abfragen auf SAP HANA Tauglichkeit
 
Cadaxo SQL Cockpit 2.0 - Neue Features im Detail
Cadaxo SQL Cockpit 2.0 - Neue Features im DetailCadaxo SQL Cockpit 2.0 - Neue Features im Detail
Cadaxo SQL Cockpit 2.0 - Neue Features im Detail
 
Abap 7 02 new features - new string functions
Abap 7 02   new features - new string functionsAbap 7 02   new features - new string functions
Abap 7 02 new features - new string functions
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Recently uploaded (20)

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 

ABAP CodeRetreat 20.5.2017 Vienna - Refactoring

Editor's Notes

  1. Im sure, most of you have heard about refactoring in the context of Test Driven Development
  2. You probably know this situation: You are looking into existing code, it‘s probably not yours, and you sad „O my good, tha‘ts realy bad code“. What was I (or the other developer) thinking? This is completely wrong! Martin Fowler calls such code „Yuck“ (=Igitt, Pfui, Pfui Teufel!) I startet my development careere 25 years ago. Back then we sad, if a code works - don‘t touch it! – If you touch it, you might brake it! - Remember „Never change a running system“ Btw: Funny fact, this pharses was only used in german-speaking countries. The Refactoring Mindeset says, when you see such bad code – you should fix it! – Maybee it was fine a year ago, when you wrote it. But now you realize, it‘s not right and you have to change it, you have to fix it. Martin Fowler describes this as Litter-Pickup! If you have read the Book “Clean Code” by Rober C. Martin then you have heard about the “Boyscout Rule”: If you have to change a code, always leave the code at least a little bit better. Make at least a small improvement! If you hit the code very often, then you will have a realy great code over the time.
  3. Sometimes you are looking into a code, and you do not understand what the code should do. „What the hell is this code doing?“ You have to analyze it, you have to go very deep into the coding to understand it. And then – I am sure you know the moment – you understand the Coding. „Bingo“ That is, what the code does! This is a important moment - but it‘s just in your head! For the moment. You can not share your brain with your team. And after a couple of months (or sometimes after a couple of hours) you have completely forgotten what the code should do. You should refactor the code to make it more clear, to make it easier to understand! Martin Fowler described this as Comprehension Refactoring Both Litter-Pickup Refactoring and Comprehension Refactoring requires the same reaction. There are 2 tracks, which you can consider: When ever you see something which you dont understand or is just bad code, you should ask yourself – „Do I wanna fix it now“. Is it a quick simple fix, or does fixing take a little bit of time. For example, if you just want to rename a method, then you can do it right now. But sometimes you have to think about the code. If you decide to fix it later, you should make a note – for example in the top area of you code – and as soon if you have finish your regular work, go back and make it a little bit cleaner.
  4. I am sure you know the situation: You look into some code and you realize, I have new insights how the code should work, that I didn‘t have bevore. Especialy in the context of adding a new feature. You have to add some new functionality to put in, and it whould be realy easy to add this new function – if the existing code was organized a little bit different. Maybe the code was o.k. when you have developed it, but now you have to add new features and it‘s not looking right anymore. This situation is called „Preparatory Refactoring“ Basically this means, before you add a new function to an existing coding which not fits in a shape that you want, refactor it! Refactor it, make the tests until they are green – and then start to add the new feature to the better refactored code base. Some people think, that refactoring slows you down, that refactoring blocks your time from other things. Usually the benefits from refactoring results in the medium term. But in this case, you can get that benefit right now in the middle of the task you are doing. Often it is faster, to do a preparatory refactoring and then add the new functionalty.
  5. People often talk about refactoring, „Why should we refactor?“ – Because we want have a good code, a clean code. Because it is the „Right Thing“. If you use these arguments in discussions with your customers, you have lost.
  6. The only valid argument is economy!
  7. We do this, to deliver more functionality more quickly! This is the only reason!
  8. We do this, to deliver more functionality more quickly! This is the only reason!