SlideShare ist ein Scribd-Unternehmen logo
1 von 100
S4H151 - Survive the
Chaos with Tips and
Tricks to Handle Legacy
ABAP CodeRainer Winkler
14 November 2017
Legacy Code
code without tests
Michael Feathers
Andrea Goulet
Legacy Code is code with
too many code smells
Code Smell
Code Smell –
something that
makes work difficult
Fail fast ->
Reduce costs to handle errors
• Error messages
• ASSERT statements
• Logging
Can be a Smell if it is missed
Write down customer
requirements
• Use a requirement engineering tool
• Use a simple Excel sheet with unique ID´s for each
requirement
Can be a Smell if it is missed
Do not focus only on
performance
• Field-Symbols are fast, but make coding also harder to
maintain
Depends on the project, the
developer and the usage
Find solutions for smells that hurt
Do not apply design rules that add
complexity without sufficient
benefit
Source: Rainer Winkler
No medicine without prescription
What to do?
Clean Code
Write automatic tests
Source https://mix.msfc.nasa.gov/abstracts.php?p=2869
Use a combination of Clean Code
and automatic tests
Decide which approach is best
Unit Tests
Why?
Unit Test to understand
Unit Test as
characterization test
Unit Test to
documentate
Integration tests
check for correctness
Example for an integration test with unit tests
Open Source project SAP2Moose
• Class z2mse_extract3
• The unit test makes direct accesses to a test application.
• It is an integration test
Errors in Unit Tests are easier
to fix than errors in Integration
Tests
• Because the place is known and the complexity is less
Only an Integration Test can
make sure that everything
works as required
• not too many Tests
• Try to documentate with tests
• New Tests should add a new aspect
• Use good names for Tests
Tips
Unit Test with dependencies
Add mock instances in tests
But
ABAP Objects is not designed
for many method calls like JAVA
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/index.htm
ABAP - Keyword Documentation → ABAP Programming Guidelines → Architecture → Object-Oriented Programming → Modularization
Is this one of the reasons
people at SAP invented
Test Seams?
Demo 1 – Test Seams
• Test first
• Create methods from test
• Test shall first fail „Test the test“
• Use a Test Seam
Tips – Test Seams
Read scn blogs
Add all injections in the setup method with a fail
How not to forget test injections?
How not to be surprised?
Test passes, where it should not
Implement Test Seams correct
Implement Test Seams correct
X
Use local class for testing with static public attributes
Can be used in Unit test and in the injected code
Can not be used in the productive code (as FOR TESTING)
How to inject variable values?
Define a local class for testing
with static public attribute
Empty Seam at place to be checked
Set attribute in injection
Check for value
How to check whether a code snippet is executed?
In earlier releases I often failed to
write Unit Test for typical ABAP
code.
It was too complex and risky
With ABAP 7.50
I am normally successful
Test Seams make writing Unit Test easier
I use Test Seams when they help
for old and for new coding
This tests are also on Github
https://github.com/RainerWinkler/ABAP-Unit-Test-Demo
Synchronized with abapGit (Why not? „Install abapGit make a fork and make a pull request to this“):
Typical workflow while changing
Legacy Code
1 Add Unit test to
- understand
- have a safety belt
2 Refactor to simplify changes
3 Change Unit test so that it passes
only after changes are made
4 Make changes in the code
There is a lot of text in Coding
I have problems to remember this
Why are there so few
"circuit diagrams" in IT?
Source https://en.wikipedia.org/wiki/File:Circuit_diagram_%E2%80%93_pictorial_and_schematic.png Author: "United States. Dept. of the Air Force"
I draw diagrams but it needs a lot of time
Can this be automatized?
SAP Inside Track
Munich 20151
1 https://wiki.scn.sap.com/wiki/display/events/SAP+Inside+Track+Munich+2015
Read papers about code comprehension
While exploring many new files,
developers gradually forget
which ones are relevant or irrelevant to their goal
and how these files are related to each other.
Lee, Seonah, and Sungwon Kang. "What situational information would help developers when using a graphical code recommender?." Journal of Systems and Software 117 (2016): 199-217.
De Alwis, Brian, and Gail C. Murphy. "Using visual momentum to explain disorientation in the Eclipse IDE." Visual Languages and Human-Centric Computing, 2006. VL/HCC 2006. IEEE Symposium on. IEEE, 2006.
While switching between these files to
understand them,
developers become disoriented.
Lee, Seonah, and Sungwon Kang. "What situational information would help developers when using a graphical code recommender?." Journal of Systems and Software 117 (2016): 199-217.
De Alwis, Brian, and Gail C. Murphy. "Using visual momentum to explain disorientation in the Eclipse IDE." Visual Languages and Human-Centric Computing, 2006. VL/HCC 2006. IEEE Symposium on. IEEE, 2006.
While performing multiple tasks simultaneously,
developers fail to focus on one task
due to the others,
and unconsciously move on to
other tasks
without accomplishing the initial task.
Lee, Seonah, and Sungwon Kang. "What situational information would help developers when using a graphical code recommender?." Journal of Systems and Software 117 (2016): 199-217.
De Alwis, Brian, and Gail C. Murphy. "Using visual momentum to explain disorientation in the Eclipse IDE." Visual Languages and Human-Centric Computing, 2006. VL/HCC 2006. IEEE Symposium on. IEEE, 2006.
I am not the only one?
SAP2Moose and
Moose2Model
Ask me:
Rainer Winkler
A Moose2Model diagram of a
complete application
Ask me:
Rainer Winkler
A Moose2Model diagram of a
part of an application
Legend
• Extracts meta information to Moose
• Does not extract source code
• Easy to install (A single report)
• Developed using abapGit
• Works on ABAP 7.02
• MIT license
SAP2Moose
• An open source Software Exploration Tool
• Designed to be used by developers working with legacy code
• Displays not only ABAP classes but also tables, WebDynpro ABAP, SAP BW...
• Jump into ABAP Eclipse with ADT and BWMT links possible
• Can be adapted
• Diagrams can be customized, elements can be commented
• Changes can be stored
• MIT license
Moose2Model
SAP2Moose - Installation
Go to SAP2Moose.org
You are forwarded to github,
Extracted are only names and relations between elements, no source code
Read Wiki - Installation
Go to Code and click on z_moose_extractor.abap
and z_moose_extractor_texts.txt
Paste code into new program, add texts from file,
run it
Moose2Model - Installation
Go to Moose2Model.org
You are forwarded to github,
read Wiki - Installation
Download the preconfigured image
Extract zip file and start Pharo.exe
The image is ready to work
No need to start a program
Smalltalk programs behave like an
Excel file, you save them, but you
do not start them (normally)
Simple Gui
Pharo leaves always some space, because desktop is needed
Display the most important at the top, it will normally be visible there
The green "thing"
Save layout information
to use it later
Moose2Model - Stopping
Make a left mouse click to the desktop
You see the World menu
Choose Save and quit
Or just Quit without saving if the exact status
of the Image is not needed to be saved
Demo 2
• Install SAP2Moose
• Run SAP2Moose
• Install Moose2Model
• Use Moose2Model
• Stop Moose2Model
How to make a diagram?
I do normally:
1. Navigate to an attribute or method and send
RWDiagram suppressOthersUsedByLayers: 1 usingLayers: 1 to: self.
2. Generate a diagram with formatting info
3. Send RWDiagram suppressOthersUsedByLayers: 1 usingLayers: 1 to: self.
to further elements as required
4. Redo the suppress... statement with
RWDiagram removeAppearanceChangersFrom: self.
if needed
5. Suppress some classes (like logging) with
RWDiagram suppressWithChildren: true to: self.
I need no Diagrams - What else can I do with it?
SAP2Moose - Multilevel Where Used
Compare with the diagram
I see too
many elements
Restrict diagram to packages
Thanks to Stefan Nothaft for believing in and requiring the option to restrict diagrams to packages and classes
or classes
I want a fast way to
navigate to the coding
SAP2Moose provides ADT1 and BWMT2 Links
1Currently not for interface methods and some other elements
2Currently only to some SAP BW transformations
Two clicks;
and method is shown in Eclipse ADT
works also for the class
There are very many elements
with nearto similar names
I am confused
Use the picture
A method that implements an
interface appears not used
SAP2Moose marks implementing method as
used by interface method - which is used
Sorry for the method names. The example is part of the integration test of SAP2Moose, the names are long to check that no information is lost due to too long names
A method appears not used
SAP2Moose marks redefining method as
used by redefined method - which is used
The diagrams are not pretty
The idea is to have as much information as possible on a page
• Straight lines leed to hair-nots,
• but they make very clear where they are pointing to
• rearranging is very easy in the tool1
1A coding to rearange elements automatically exists, but is currently not used by the author, because manual rearranging appears to be more convenient
Moose2Model is not designed for nice presentations
I need to exchange diagrams
with colleagues
Diagram information is exported as xml
Can be synchronized with a version control system
See e.g. subfolder models
of SAP2Moose and
Moose2Model
I use other computer languages
or something that is
not even called programming
• Like SAP BW
Moose Analysis is designed for many languages
SAP2Moose maps:
• "coding" to methods
• "data bearing entities" to attributes
• "groupings" to classes
• "higher level groupings" to packages
Elements are dynamically called
I do not see this in Where Used
Add a comment in
Moose2Model1:
1This only a demo. The method Z2MSE_MSE_HARMONIZE>>MSE_2_HARMONIZED is used in unit tests, these are currently not extracted by SAP2Moose
It is planned to support custom logic
to add such dependencies to the extracted model
All what is done with SAP2Moose
and Moose2Model can also be done without
- So why do I need it?
The problem is not do perform a single task
- Complex coding, Legacy coding - requires that many tasks are done
with limited time and budget
I used to make about a dozen diagrams per year
With SAP2Moose and Moose2Model
I make thousands
The diagram is not as expected
This happens quite often
Often caused by "trivial" bugs
Difficult to see in the coding but
easy to see in a diagram
This reduces the cost to find
and fix errors
I am confused by wrong names
Add a comment
to explain what the real meaning is
1Names could be renamed in SAP2Moose or Moose2Model if needed
"Virtual" renaming is an option1
Why not plantUML?
plantUML is great for UML
But analyzing existing code needs more details
Moose uses FAMIX and is able to extract more detailed informations
It is possible to design a new software based on classes
But it is NOT possible to understand problematic software
by analyzing classes
plantUML is a tool to draw diagrams,
Moose2Model and SAP2Moose are Software Exploration Tools
Why no display of inheritances?
Why no info on attributes like
static, public, private?
Such informations can be stored and
analyzed in Moose Analysis
But to analyze dependencies of
existing code, I do not regard this needed
How to understand which
dependencies
are shown?
Generate a diagram with formatting info
Z2MSE_EXTR3_ELEMENTS>>MAKE_MODEL
is not highlighted because it contains
the information to display all
connected elements
Only a workaround that works if allways
using and used by layers is set to greater zero
Where to send statements to Moose elements?
In the Moose Panel
Context menu "Do it" Ctrl-D
Where to send statements to Moose elements?
In the inspector of a diagram
Click on the element
Context menu "Do it" Ctrl-D
Where to send statements to Moose elements?
Wherever you find it.
It exists as instance in the image. You can alway send
statements and questions to it.
I draw diagrams
If I make an error,
I will make wrong decisions
SAP2Moose and Moose2Model have
limitations and errors
• These are reproducible and I can learn to circumvent then
• Generally the total number of errors is much less
compared to a developer who analyzes an application
solely manually
What are the elements I work with?
Make a diagram with all these
Layout
Moose2Model Issue 39 Simplify handling of diagrams
available also on Github
Find obsolete coding
Method is not used in the diagram
Other option: Find potentially obsolete Methods in Moose Panel with:
each incomingInvocations size = 0
Thank you!
SAP2Moose and Moose2Model would never
be possible without
Damir Majer
Tudor Girba
Alexandré Bergel
And many others,
I have no place to mention here
Have fun 
Look for Test Seam on SCN
sap2moose.org
moose2model.org
Twitter: @rainerwinkler
Open an issue on github,
this is the most efficient way to get help
- Not understanding points to bad documentation
-> The easiest way to help is to documentate <-

Weitere ähnliche Inhalte

Was ist angesagt?

Software Automation Testing Introduction
Software Automation Testing IntroductionSoftware Automation Testing Introduction
Software Automation Testing IntroductionNarayanan Palani
 
Java days Lviv 2015
Java days Lviv 2015Java days Lviv 2015
Java days Lviv 2015Alex Theedom
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxMikalai Alimenkou
 
Coding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever ChangedCoding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever ChangedElizabeth Quinn-Woods
 
Awesome Test Automation Made Simple w/ Dave Haeffner
Awesome Test Automation Made Simple w/ Dave HaeffnerAwesome Test Automation Made Simple w/ Dave Haeffner
Awesome Test Automation Made Simple w/ Dave HaeffnerSauce Labs
 
How to explain what JRebel does to a developer
How to explain what JRebel does to a developerHow to explain what JRebel does to a developer
How to explain what JRebel does to a developerBogomil Shopov
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object PatternDante Briones
 
Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18James Leone
 
How to Prepare for the OCPJP 8 Exam?
How to Prepare for the OCPJP 8 Exam?How to Prepare for the OCPJP 8 Exam?
How to Prepare for the OCPJP 8 Exam?Ganesh Samarthyam
 
Architecture of automated test cases for legacy applications
Architecture of automated test cases for legacy applicationsArchitecture of automated test cases for legacy applications
Architecture of automated test cases for legacy applicationsMikhail Vasylchenko
 
I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingPeter Presnell
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern RiverGlide
 
Introduction to UI Automation Framework
Introduction to UI Automation FrameworkIntroduction to UI Automation Framework
Introduction to UI Automation FrameworkPriya Rajagopal
 
Sustainable Automation Frameworks by Kelsey Shannahan
Sustainable Automation Frameworks by Kelsey ShannahanSustainable Automation Frameworks by Kelsey Shannahan
Sustainable Automation Frameworks by Kelsey ShannahanQA or the Highway
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Steven Smith
 

Was ist angesagt? (19)

Software Automation Testing Introduction
Software Automation Testing IntroductionSoftware Automation Testing Introduction
Software Automation Testing Introduction
 
Java days Lviv 2015
Java days Lviv 2015Java days Lviv 2015
Java days Lviv 2015
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
 
Coding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever ChangedCoding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever Changed
 
Introduction To AOP
Introduction To AOPIntroduction To AOP
Introduction To AOP
 
Awesome Test Automation Made Simple w/ Dave Haeffner
Awesome Test Automation Made Simple w/ Dave HaeffnerAwesome Test Automation Made Simple w/ Dave Haeffner
Awesome Test Automation Made Simple w/ Dave Haeffner
 
Automated testing web application
Automated testing web applicationAutomated testing web application
Automated testing web application
 
How to explain what JRebel does to a developer
How to explain what JRebel does to a developerHow to explain what JRebel does to a developer
How to explain what JRebel does to a developer
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
Tech breakfast 18
Tech breakfast 18Tech breakfast 18
Tech breakfast 18
 
How to Prepare for the OCPJP 8 Exam?
How to Prepare for the OCPJP 8 Exam?How to Prepare for the OCPJP 8 Exam?
How to Prepare for the OCPJP 8 Exam?
 
Architecture of automated test cases for legacy applications
Architecture of automated test cases for legacy applicationsArchitecture of automated test cases for legacy applications
Architecture of automated test cases for legacy applications
 
I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application Testing
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern
 
Introduction to UI Automation Framework
Introduction to UI Automation FrameworkIntroduction to UI Automation Framework
Introduction to UI Automation Framework
 
Sustainable Automation Frameworks by Kelsey Shannahan
Sustainable Automation Frameworks by Kelsey ShannahanSustainable Automation Frameworks by Kelsey Shannahan
Sustainable Automation Frameworks by Kelsey Shannahan
 
Custom JSF components
Custom JSF componentsCustom JSF components
Custom JSF components
 
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
Breaking Dependencies to Allow Unit Testing - DevIntersection Spring 2016
 

Ähnlich wie Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture

Sap inside track Munich 2017
Sap inside track Munich 2017Sap inside track Munich 2017
Sap inside track Munich 2017Rainer Winkler
 
Performance analysis of synchronisation problem
Performance analysis of synchronisation problemPerformance analysis of synchronisation problem
Performance analysis of synchronisation problemharshit200793
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentGabriel Walt
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure rupeshchanchal
 
What would Jesus Developer do?
What would Jesus Developer do?What would Jesus Developer do?
What would Jesus Developer do?Lukáš Čech
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...Paul Jensen
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net coreSam Nasr, MCSA, MVP
 
[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?European Collaboration Summit
 
Introduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald BelchamIntroduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald Belcham.NET Conf UY
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Enkitec
 
Maintainable Javascript carsonified
Maintainable Javascript carsonifiedMaintainable Javascript carsonified
Maintainable Javascript carsonifiedChristian Heilmann
 
Postmortem of a uwp xaml application development
Postmortem of a uwp xaml application developmentPostmortem of a uwp xaml application development
Postmortem of a uwp xaml application developmentDavid Catuhe
 
Cs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ reportCs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ reportKhushboo Wadhwani
 
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedJoão Pedro Martins
 
Using MLOps to Bring ML to Production/The Promise of MLOps
Using MLOps to Bring ML to Production/The Promise of MLOpsUsing MLOps to Bring ML to Production/The Promise of MLOps
Using MLOps to Bring ML to Production/The Promise of MLOpsWeaveworks
 
Cardiff University FTS presentation 2011 (MS Word plug in)
Cardiff University FTS presentation 2011 (MS Word plug in)Cardiff University FTS presentation 2011 (MS Word plug in)
Cardiff University FTS presentation 2011 (MS Word plug in)salsalamah
 
How can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdfHow can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdfMindfire LLC
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmerLeylimYaln
 

Ähnlich wie Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture (20)

Sap inside track Munich 2017
Sap inside track Munich 2017Sap inside track Munich 2017
Sap inside track Munich 2017
 
Performance analysis of synchronisation problem
Performance analysis of synchronisation problemPerformance analysis of synchronisation problem
Performance analysis of synchronisation problem
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 
Best practices for structuring Machine Learning code
Best practices for structuring Machine Learning codeBest practices for structuring Machine Learning code
Best practices for structuring Machine Learning code
 
What would Jesus Developer do?
What would Jesus Developer do?What would Jesus Developer do?
What would Jesus Developer do?
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 
[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?[Pinto] Is my SharePoint Development team properly enlighted?
[Pinto] Is my SharePoint Development team properly enlighted?
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
Introduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald BelchamIntroduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald Belcham
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12
 
Maintainable Javascript carsonified
Maintainable Javascript carsonifiedMaintainable Javascript carsonified
Maintainable Javascript carsonified
 
Postmortem of a uwp xaml application development
Postmortem of a uwp xaml application developmentPostmortem of a uwp xaml application development
Postmortem of a uwp xaml application development
 
Cs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ reportCs690 object oriented_software_engineering_team01_ report
Cs690 object oriented_software_engineering_team01_ report
 
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
 
Using MLOps to Bring ML to Production/The Promise of MLOps
Using MLOps to Bring ML to Production/The Promise of MLOpsUsing MLOps to Bring ML to Production/The Promise of MLOps
Using MLOps to Bring ML to Production/The Promise of MLOps
 
Cardiff University FTS presentation 2011 (MS Word plug in)
Cardiff University FTS presentation 2011 (MS Word plug in)Cardiff University FTS presentation 2011 (MS Word plug in)
Cardiff University FTS presentation 2011 (MS Word plug in)
 
How can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdfHow can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdf
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmer
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture

  • 1. S4H151 - Survive the Chaos with Tips and Tricks to Handle Legacy ABAP CodeRainer Winkler 14 November 2017
  • 2. Legacy Code code without tests Michael Feathers
  • 4. Legacy Code is code with too many code smells
  • 6. Code Smell – something that makes work difficult
  • 7. Fail fast -> Reduce costs to handle errors • Error messages • ASSERT statements • Logging Can be a Smell if it is missed
  • 8. Write down customer requirements • Use a requirement engineering tool • Use a simple Excel sheet with unique ID´s for each requirement Can be a Smell if it is missed
  • 9. Do not focus only on performance • Field-Symbols are fast, but make coding also harder to maintain
  • 10. Depends on the project, the developer and the usage
  • 11. Find solutions for smells that hurt
  • 12. Do not apply design rules that add complexity without sufficient benefit
  • 14. No medicine without prescription
  • 17. Write automatic tests Source https://mix.msfc.nasa.gov/abstracts.php?p=2869
  • 18. Use a combination of Clean Code and automatic tests
  • 21. Unit Test to understand
  • 25. Example for an integration test with unit tests Open Source project SAP2Moose • Class z2mse_extract3 • The unit test makes direct accesses to a test application. • It is an integration test
  • 26. Errors in Unit Tests are easier to fix than errors in Integration Tests • Because the place is known and the complexity is less
  • 27. Only an Integration Test can make sure that everything works as required
  • 28. • not too many Tests • Try to documentate with tests • New Tests should add a new aspect • Use good names for Tests Tips
  • 29. Unit Test with dependencies
  • 30. Add mock instances in tests
  • 31. But
  • 32. ABAP Objects is not designed for many method calls like JAVA
  • 33. https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/index.htm ABAP - Keyword Documentation → ABAP Programming Guidelines → Architecture → Object-Oriented Programming → Modularization
  • 34. Is this one of the reasons people at SAP invented Test Seams?
  • 35. Demo 1 – Test Seams • Test first • Create methods from test • Test shall first fail „Test the test“ • Use a Test Seam
  • 36. Tips – Test Seams
  • 38. Add all injections in the setup method with a fail How not to forget test injections?
  • 39. How not to be surprised?
  • 40. Test passes, where it should not
  • 42. Implement Test Seams correct X
  • 43. Use local class for testing with static public attributes Can be used in Unit test and in the injected code Can not be used in the productive code (as FOR TESTING) How to inject variable values?
  • 44. Define a local class for testing with static public attribute Empty Seam at place to be checked Set attribute in injection Check for value How to check whether a code snippet is executed?
  • 45. In earlier releases I often failed to write Unit Test for typical ABAP code. It was too complex and risky
  • 46. With ABAP 7.50 I am normally successful Test Seams make writing Unit Test easier
  • 47. I use Test Seams when they help for old and for new coding
  • 48. This tests are also on Github https://github.com/RainerWinkler/ABAP-Unit-Test-Demo Synchronized with abapGit (Why not? „Install abapGit make a fork and make a pull request to this“):
  • 49.
  • 50. Typical workflow while changing Legacy Code 1 Add Unit test to - understand - have a safety belt 2 Refactor to simplify changes 3 Change Unit test so that it passes only after changes are made 4 Make changes in the code
  • 51.
  • 52. There is a lot of text in Coding I have problems to remember this Why are there so few "circuit diagrams" in IT?
  • 54. I draw diagrams but it needs a lot of time Can this be automatized? SAP Inside Track Munich 20151 1 https://wiki.scn.sap.com/wiki/display/events/SAP+Inside+Track+Munich+2015
  • 55. Read papers about code comprehension
  • 56. While exploring many new files, developers gradually forget which ones are relevant or irrelevant to their goal and how these files are related to each other. Lee, Seonah, and Sungwon Kang. "What situational information would help developers when using a graphical code recommender?." Journal of Systems and Software 117 (2016): 199-217. De Alwis, Brian, and Gail C. Murphy. "Using visual momentum to explain disorientation in the Eclipse IDE." Visual Languages and Human-Centric Computing, 2006. VL/HCC 2006. IEEE Symposium on. IEEE, 2006.
  • 57. While switching between these files to understand them, developers become disoriented. Lee, Seonah, and Sungwon Kang. "What situational information would help developers when using a graphical code recommender?." Journal of Systems and Software 117 (2016): 199-217. De Alwis, Brian, and Gail C. Murphy. "Using visual momentum to explain disorientation in the Eclipse IDE." Visual Languages and Human-Centric Computing, 2006. VL/HCC 2006. IEEE Symposium on. IEEE, 2006.
  • 58. While performing multiple tasks simultaneously, developers fail to focus on one task due to the others, and unconsciously move on to other tasks without accomplishing the initial task. Lee, Seonah, and Sungwon Kang. "What situational information would help developers when using a graphical code recommender?." Journal of Systems and Software 117 (2016): 199-217. De Alwis, Brian, and Gail C. Murphy. "Using visual momentum to explain disorientation in the Eclipse IDE." Visual Languages and Human-Centric Computing, 2006. VL/HCC 2006. IEEE Symposium on. IEEE, 2006.
  • 59. I am not the only one?
  • 61. Ask me: Rainer Winkler A Moose2Model diagram of a complete application
  • 62.
  • 63. Ask me: Rainer Winkler A Moose2Model diagram of a part of an application
  • 64.
  • 66. • Extracts meta information to Moose • Does not extract source code • Easy to install (A single report) • Developed using abapGit • Works on ABAP 7.02 • MIT license SAP2Moose
  • 67. • An open source Software Exploration Tool • Designed to be used by developers working with legacy code • Displays not only ABAP classes but also tables, WebDynpro ABAP, SAP BW... • Jump into ABAP Eclipse with ADT and BWMT links possible • Can be adapted • Diagrams can be customized, elements can be commented • Changes can be stored • MIT license Moose2Model
  • 68. SAP2Moose - Installation Go to SAP2Moose.org You are forwarded to github, Extracted are only names and relations between elements, no source code Read Wiki - Installation Go to Code and click on z_moose_extractor.abap and z_moose_extractor_texts.txt Paste code into new program, add texts from file, run it
  • 69. Moose2Model - Installation Go to Moose2Model.org You are forwarded to github, read Wiki - Installation Download the preconfigured image Extract zip file and start Pharo.exe The image is ready to work No need to start a program Smalltalk programs behave like an Excel file, you save them, but you do not start them (normally)
  • 70. Simple Gui Pharo leaves always some space, because desktop is needed Display the most important at the top, it will normally be visible there The green "thing"
  • 72. Moose2Model - Stopping Make a left mouse click to the desktop You see the World menu Choose Save and quit Or just Quit without saving if the exact status of the Image is not needed to be saved
  • 73. Demo 2 • Install SAP2Moose • Run SAP2Moose • Install Moose2Model • Use Moose2Model • Stop Moose2Model
  • 74. How to make a diagram? I do normally: 1. Navigate to an attribute or method and send RWDiagram suppressOthersUsedByLayers: 1 usingLayers: 1 to: self. 2. Generate a diagram with formatting info 3. Send RWDiagram suppressOthersUsedByLayers: 1 usingLayers: 1 to: self. to further elements as required 4. Redo the suppress... statement with RWDiagram removeAppearanceChangersFrom: self. if needed 5. Suppress some classes (like logging) with RWDiagram suppressWithChildren: true to: self.
  • 75.
  • 76. I need no Diagrams - What else can I do with it? SAP2Moose - Multilevel Where Used Compare with the diagram
  • 77. I see too many elements Restrict diagram to packages Thanks to Stefan Nothaft for believing in and requiring the option to restrict diagrams to packages and classes or classes
  • 78. I want a fast way to navigate to the coding SAP2Moose provides ADT1 and BWMT2 Links 1Currently not for interface methods and some other elements 2Currently only to some SAP BW transformations Two clicks; and method is shown in Eclipse ADT works also for the class
  • 79. There are very many elements with nearto similar names I am confused Use the picture
  • 80. A method that implements an interface appears not used SAP2Moose marks implementing method as used by interface method - which is used Sorry for the method names. The example is part of the integration test of SAP2Moose, the names are long to check that no information is lost due to too long names
  • 81. A method appears not used SAP2Moose marks redefining method as used by redefined method - which is used
  • 82. The diagrams are not pretty
  • 83. The idea is to have as much information as possible on a page • Straight lines leed to hair-nots, • but they make very clear where they are pointing to • rearranging is very easy in the tool1 1A coding to rearange elements automatically exists, but is currently not used by the author, because manual rearranging appears to be more convenient Moose2Model is not designed for nice presentations
  • 84. I need to exchange diagrams with colleagues Diagram information is exported as xml Can be synchronized with a version control system See e.g. subfolder models of SAP2Moose and Moose2Model
  • 85. I use other computer languages or something that is not even called programming • Like SAP BW Moose Analysis is designed for many languages SAP2Moose maps: • "coding" to methods • "data bearing entities" to attributes • "groupings" to classes • "higher level groupings" to packages
  • 86. Elements are dynamically called I do not see this in Where Used Add a comment in Moose2Model1: 1This only a demo. The method Z2MSE_MSE_HARMONIZE>>MSE_2_HARMONIZED is used in unit tests, these are currently not extracted by SAP2Moose It is planned to support custom logic to add such dependencies to the extracted model
  • 87. All what is done with SAP2Moose and Moose2Model can also be done without - So why do I need it? The problem is not do perform a single task - Complex coding, Legacy coding - requires that many tasks are done with limited time and budget I used to make about a dozen diagrams per year With SAP2Moose and Moose2Model I make thousands
  • 88. The diagram is not as expected This happens quite often Often caused by "trivial" bugs Difficult to see in the coding but easy to see in a diagram This reduces the cost to find and fix errors
  • 89. I am confused by wrong names Add a comment to explain what the real meaning is 1Names could be renamed in SAP2Moose or Moose2Model if needed "Virtual" renaming is an option1
  • 90. Why not plantUML? plantUML is great for UML But analyzing existing code needs more details Moose uses FAMIX and is able to extract more detailed informations It is possible to design a new software based on classes But it is NOT possible to understand problematic software by analyzing classes plantUML is a tool to draw diagrams, Moose2Model and SAP2Moose are Software Exploration Tools
  • 91. Why no display of inheritances? Why no info on attributes like static, public, private? Such informations can be stored and analyzed in Moose Analysis But to analyze dependencies of existing code, I do not regard this needed
  • 92. How to understand which dependencies are shown? Generate a diagram with formatting info Z2MSE_EXTR3_ELEMENTS>>MAKE_MODEL is not highlighted because it contains the information to display all connected elements Only a workaround that works if allways using and used by layers is set to greater zero
  • 93. Where to send statements to Moose elements? In the Moose Panel Context menu "Do it" Ctrl-D
  • 94. Where to send statements to Moose elements? In the inspector of a diagram Click on the element Context menu "Do it" Ctrl-D
  • 95. Where to send statements to Moose elements? Wherever you find it. It exists as instance in the image. You can alway send statements and questions to it.
  • 96. I draw diagrams If I make an error, I will make wrong decisions SAP2Moose and Moose2Model have limitations and errors • These are reproducible and I can learn to circumvent then • Generally the total number of errors is much less compared to a developer who analyzes an application solely manually
  • 97. What are the elements I work with? Make a diagram with all these Layout Moose2Model Issue 39 Simplify handling of diagrams available also on Github
  • 98. Find obsolete coding Method is not used in the diagram Other option: Find potentially obsolete Methods in Moose Panel with: each incomingInvocations size = 0
  • 99. Thank you! SAP2Moose and Moose2Model would never be possible without Damir Majer Tudor Girba Alexandré Bergel And many others, I have no place to mention here
  • 100. Have fun  Look for Test Seam on SCN sap2moose.org moose2model.org Twitter: @rainerwinkler Open an issue on github, this is the most efficient way to get help - Not understanding points to bad documentation -> The easiest way to help is to documentate <-