Presentation refactoring large legacy applications
-
Upload
jorge-capel-planells -
Category
Software
-
view
790 -
download
2
Transcript of Presentation refactoring large legacy applications
![Page 1: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/1.jpg)
© 2015 Nunsys
Refactoring long-living legacy applications
Manuel Alagarda Esteve
Consultor Business Software
![Page 2: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/2.jpg)
© 2015 Nunsys
A few things about me
Jorge Capel PlanellsConsultor Business Software at NUNSYS
@jcapelplanells
![Page 3: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/3.jpg)
© 2015 Nunsys
The Life path of a long-living application
Una evolución poco sostenible hoy, un sistema inviable mañana.
![Page 4: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/4.jpg)
Infeasibility Stage
Sibylle Peter, Sven Ehrke, Canoo Engineering AG, www.canoo.com
http://www.methodsandtools.com/archive/archive.php?id=98
![Page 5: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/5.jpg)
Do you have a legacy application problem?
• Are you working in a critical application for your business or Company?
• Does your company grow faster than your application?
• Is your application able to achieve business goals in time?
• Do you spend a lot of time and effort working in a new feature?
• Could a simple change take weeks?
• Do you invest a lot of time and effort fixing bugs?
• Do you have a safety net of automated regression tests ?
• Deliver a new version makes your heart sink?
![Page 6: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/6.jpg)
Yes, you have a problem
![Page 7: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/7.jpg)
Infeasibility application
….hero work
![Page 8: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/8.jpg)
Why do you have a legacy problem?
![Page 9: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/9.jpg)
© 2015 Nunsys
Refactor or Rewrite??
Factores en los que nos basamos para tomar a esta decisión
![Page 10: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/10.jpg)
Refactoring
“Refactoring is the process of changing a software system in such a way that it does not alter theexternal behavior of the code yet improves its internal structure.”
Refactoring: Improving the Design of Existing CodeMartin Fowler
![Page 11: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/11.jpg)
Key factors
1 Time to market
2 Continuous changes
3 Techical debt
4 Application size
5 Complexity
6 Cost of application redesign
![Page 12: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/12.jpg)
Refactor or Rewrite??
Technical debt
Changes
Time-to-market
Size
Complex
Cost new application
Refactor o Rewrite?
REESCRIBIR
High technical debt
Low cost of new application
REWRITE
Technical debt 9
Changes 9
Time-to-market 10
Size 1
Complex 1
Cost of new application 3
![Page 13: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/13.jpg)
Refactor or Rewrite?
Technical debt
Changes
Time-to-market
Size
Complexity
Cost of new application
Refactor o rewrite?
REFACTOR
Always refactor with low
technical debt
Technical debt 2
Changes 9
Time-to-market 10
Size 7
Complex 8
Cost of new application 8
![Page 14: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/14.jpg)
Refactor or Rewrite?
Technical debt
Changes
Time-to-market
Size
Complex
Cost of new application
Refactor or Rewrite?
Very high Technical debt
Low changes
Technical debt 8
Changes 2
Time-to-market 2
Size 5
Complex 5
Cost of new application 5
![Page 15: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/15.jpg)
Refactor or Rewrite?
Technical debt
Changes
Time-to-market
Size
Complex
Cost of new application
Refactor or Rewrite?
REFACTORTechnical debt 6
Changes 10
Time-to-market 10
Size 10
Complex 8
Cost of new application 10
![Page 16: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/16.jpg)
© 2015 Nunsys
Case study
Técnicas especificas de un proyecto de refactorización
![Page 17: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/17.jpg)
o Multinational car rental company located in 8 countries
o With its own IT departament and development team
o This team maintains and develops Company’s software
assets
o Software asset under study is a desktop application
8 years old
Aprox. 3,000,000 lines of code
Installed in 200 Workstation
300 users
A case study
![Page 18: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/18.jpg)
o Deliver new functionality to production every 2 weeks
o Plenty of showstopper bugs in production
o At least two hotfixes for each release
o We spend at least 20 percent of our time each iteration fixing production bugs
o High time to market
o High risk of failure. High cost of defects
o No automated tests
o No testing process
State
![Page 19: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/19.jpg)
© 2015 Nunsys
Prerequisites for succesful Refactoring Projects
Condiciones y tareas previas requeridas para poder dar comienzo con un proyecto de refactorización
![Page 20: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/20.jpg)
Management support
Management support is vital to success
• Understand the value of investing in legacy systems is difficult.
• We have to invest more time and money in an application that after allit works as required
• It’s an opportunity to explain what improvements can help your business achieve.
![Page 21: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/21.jpg)
Numbers - ROI
0
5000
10000
15000
20000
25000
30000
0 50 100 150 200 250 300 350 400 450
Cost
Features
Total cost per features
No refactor Refactoring Rewrite
Cost
Refactoring 5.000
Rewrite 15.000
Cost/Feauture
Without
Refactor 60
Refactoring 30
Rewrite 10
![Page 22: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/22.jpg)
Refactoring master plan
ASSESSMENT PERIOD
•Investigate the reasons for the deteriorated state of the application
•Identify differentiators areas that constantly change
•Identify differentiators areas that are critical for business achieve
•Identify areas that changes are expensive
![Page 23: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/23.jpg)
Refactoring master plan
GOALS
•A clear separation between layers
•Clean up the presentation layer
•Replace GUI framework
![Page 24: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/24.jpg)
Refactoring master plan
METRICS
• Quality KPI’s(Technical debt, cyclomatic complexity,cohesion,…)
• Tools: Sonar, Understand,…
Define own KPI’s
•Cost per feature
•Cost per defect
•DRE (Defect removal efficiency)
![Page 25: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/25.jpg)
Team
Trained and experienced
professionals
…and with the resources
needed
![Page 26: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/26.jpg)
Iterative and incremental development
Project must have its own team refactoring “Refactor team”
“Refactor team” must not develop new features
PREPARATORY PHASE IMPLEMENTATION PHASE
User
cases
Master
Plan
Design Parallel Tests
tool
Iteration 0
Analysis Refactor Refactor P.T
Validaton Iteraction 1
Analysis Refactor Refactor PP
Validation Iteration n
Analysis Refactor Refactor PP
Validación
![Page 27: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/27.jpg)
Version control and continuos integration
RELEASE
REFACTORING
trunk
RAMA FUNCIONALIDAD NUEVA
Versión probadaTested version
New feature branch
![Page 28: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/28.jpg)
Custom framework and working method
•Standard development guide
–SOLID
–CLEAN CODE
•Define application architecture
•Use adequate technologies
•Use frameworks
![Page 29: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/29.jpg)
Test automation
• Automate more critical user cases with Functional GUI Testing automation
• Parallel testing “Pruebas paralelas”
![Page 30: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/30.jpg)
© 2015 Nunsys
Main problems
Técnicas especificas de un proyecto de refactorización
![Page 31: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/31.jpg)
© 2015 Nunsys
How can I extract the knowledge?
![Page 32: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/32.jpg)
Reverse engineering
![Page 33: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/33.jpg)
Reverse engineering
![Page 34: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/34.jpg)
Flow diagrams
![Page 35: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/35.jpg)
© 2015 Nunsys
Where should I Start?
![Page 36: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/36.jpg)
Mikado Method
Technique used to identify and to plan refactoring tasks
![Page 37: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/37.jpg)
Mikado Method
![Page 38: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/38.jpg)
Let’s do it
![Page 39: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/39.jpg)
![Page 40: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/40.jpg)
Our process
![Page 41: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/41.jpg)
© 2015 Nunsys
I can´t do it in only one iteration
![Page 42: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/42.jpg)
I can´t do it in only one iteration
![Page 43: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/43.jpg)
Branch by abstraction
![Page 44: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/44.jpg)
Starting point
![Page 45: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/45.jpg)
?????
![Page 46: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/46.jpg)
Final implementation
![Page 47: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/47.jpg)
© 2015 Nunsys
I’ Cant test the legacy application
![Page 48: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/48.jpg)
© 2015 Nunsys
Testing legacy applications
Evitar errores mediante la automatización de pruebas
![Page 49: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/49.jpg)
Parallel Testing
• It’s an “integration test” that runs twice with differents versions• Reference version (code before refactoring)
• Refactor version (code after refactoring)
• Test must be designed to execute a critical process against a high data volumen. Test must cover all critical paths
• Two executions are independents and each one access to a identical DB.
• Finally DBs are compared in order to look for differences
![Page 50: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/50.jpg)
Parallel Testing
![Page 51: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/51.jpg)
Parallel Testing
![Page 52: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/52.jpg)
Which version is our reference?
RELEASE
REFACTORING
trunk
RAMA FUNCIONALIDAD NUEVA
Versión probadaTested version
New feature branch
![Page 53: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/53.jpg)
Functional GUI Testing automation
https://www.youtube.com/watch?v=JzAvIrk6uVI
https://www.youtube.com/watch?v=ciDVHebNphc&list=PLEBB611A728FE430E
Demostración
![Page 54: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/54.jpg)
More info about refactoring
Refactoring: Improving the Design of Existing Code – Martin Fowler
Working Efectivelly with Legacy Code - Michael Feathers
https://sourcemaking.com/refactoring
![Page 55: Presentation refactoring large legacy applications](https://reader031.fdocuments.net/reader031/viewer/2022022419/58a8e38b1a28aba6598b4b77/html5/thumbnails/55.jpg)