refactoring pyramid of - java2days
TRANSCRIPT
![Page 1: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/1.jpg)
Pyramid of Refactoring
![Page 2: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/2.jpg)
About meWłodek KrakowskiTechnical and Organizational Trainer www.refactoring.pl
2
@wlodekkr
![Page 3: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/3.jpg)
RefactoringWorkshops
3© Copyright 2019 www.refactoring.pl
![Page 4: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/4.jpg)
What isRefactoring
1
Basics
![Page 5: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/5.jpg)
Refactoring Definition
5© Copyright 2019 www.refactoring.pl
(verb) to restructure software by applying a series of refactorings without changing its observable behaviour
Martin Fowler - Refactoring (2018)
![Page 6: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/6.jpg)
Refactoring Definition
6© Copyright 2019 www.refactoring.pl
(noun) A change made to the internal structure of the software to make it easier to understand and cheaper to modify without changing its observable behaviour
Martin Fowler - Refactoring (2018)
![Page 7: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/7.jpg)
Noticingthe Pyramid
2
My story
![Page 8: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/8.jpg)
100+ WorkshopsAfterthoughts
8© Copyright 2019 www.refactoring.pl
![Page 9: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/9.jpg)
Space between two main books...
9© Copyright 2019 www.refactoring.pl
![Page 10: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/10.jpg)
Refactoring by Martin Fowler
● Great catalogue of refactorings● One big sample at the beginning● Java/Javascript
This book is a great summary but it is like encyklopedia / dictionary to me
10© Copyright 2019 www.refactoring.pl
![Page 11: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/11.jpg)
Refactoring to Patterns by Joshua Kerievsky
● Expands the subject a lot● Contains lots of smaller samples● Requires reading a few times...
But each sample is already prepared to refactoring towards given design pattern This is rarely the case in legacy code
11© Copyright 2019 www.refactoring.pl
![Page 12: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/12.jpg)
Working with Legacy Code by Michael Feathers
● Different perspective● Also a kind of encyklopedia● Allows to find a starting point !!!
Does it contain a bigger vision among lots of useful & invaluable fixes?
12© Copyright 2019 www.refactoring.pl
![Page 13: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/13.jpg)
Basics...Arrangement...Order...
13
G
m
© Copyright 2019 www.refactoring.pl
![Page 14: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/14.jpg)
Pyramid of refactoring
Some theory at the beginning
3
![Page 15: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/15.jpg)
So simple?
15© Copyright 2019 www.refactoring.pl
![Page 16: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/16.jpg)
Flow● Nested Conditions● Nested Loops● Many Local Variables● Ambiguous Names● Single Exit Points
Can you read your code like a good book from the top and understand it quickly?
16© Copyright 2019 www.refactoring.pl
![Page 17: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/17.jpg)
Methods● Levels of Abstraction● Extract / Remove Parameter● Cohesion
Can you understand quickly what a method does at single level of abstraction?
17© Copyright 2019 www.refactoring.pl
![Page 18: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/18.jpg)
Classes● Extract Delegate● Extract Base Class● Extract Subclass● Extract field/constant
Do your classes have distinct areas of responsibility?
18© Copyright 2019 www.refactoring.pl
![Page 19: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/19.jpg)
Patterns● Abstractions● Interfaces
Dependencies defined as contract instead of implementation details knowledge
19© Copyright 2019 www.refactoring.pl
![Page 20: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/20.jpg)
Architectures● Packages● Modules● (Micro) Services
Can your architecture grow and scale easily by adding new or dividing existing components?
20© Copyright 2019 www.refactoring.pl
![Page 21: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/21.jpg)
Testing and Refactoring Twins
21© Copyright 2019 www.refactoring.pl
![Page 22: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/22.jpg)
Live Refactoring
You need to experience in order to understand
4
![Page 23: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/23.jpg)
Real Estates Catalogue
23© Copyright 2019 www.refactoring.pl
![Page 24: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/24.jpg)
Initial Project...
24© Copyright 2019 www.refactoring.pl
![Page 25: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/25.jpg)
It’s not me,It’s the team...
25© Copyright 2019 www.refactoring.pl
![Page 26: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/26.jpg)
LiveRefactoring
26© Copyright 2019 www.refactoring.pl
![Page 27: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/27.jpg)
27
We are climbing up the pyramid!
© Copyright 2019 www.refactoring.pl
![Page 28: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/28.jpg)
Lots of ways to refactor...
28© Copyright 2019 www.refactoring.pl
Specs classes achieved- Create Class (manually)
- Extract Delegate / Class
- Extract Parameter Object
![Page 29: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/29.jpg)
Live Refactoring
29© Copyright 2019 www.refactoring.pl
![Page 30: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/30.jpg)
S.O.L.I.D. in Pyramid
Basics again...
5
![Page 31: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/31.jpg)
S.O.L.I.D. Refactorings
31© Copyright 2019 www.refactoring.pl
● Single Responsibility Principle○ BelowAreaSpec, MaterialSpec, ...
● Interface Segregation Principle○ Spec
● Open Closed Principle○ ProductFinder.bySpec(Spec spec)
● Dependency Inversion Principle○ pl.refactoring.search.ProductFinder○ pl.refactoring.search.Spec○ pl.refactoring.search.spec.ColorSpec
![Page 32: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/32.jpg)
32© Copyright 2019 www.refactoring.pl
![Page 33: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/33.jpg)
Make it happen
Knowledge is the beginning...
6
![Page 34: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/34.jpg)
Share new experience
34© Copyright 2019 www.refactoring.pl
Emotions come first after each ● Workshop● Conference● Meeting● New Experience
… when you’ve learned something new
![Page 35: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/35.jpg)
Get new skills
35© Copyright 2019 www.refactoring.pl
Knowledge and skills are needed to keep the emotions● Review current skills● Make a learning plan● Introduce new skills step by step
![Page 36: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/36.jpg)
Emotions and Mind
36© Copyright 2019 www.refactoring.pl
![Page 37: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/37.jpg)
Trigger / Enablerefactoring
37© Copyright 2019 www.refactoring.pl
Code review opportunities● Readability● Testability● Extendibility● Design
Teamwork - each team member has equals rights to teach and learn
![Page 38: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/38.jpg)
VisualizeQuality Activities
38© Copyright 2019 www.refactoring.pl
To Do
Dev Code Review
Rework / Refactoring
Testing /Acceptance
DoneTo Do
Dev Code Review
Rework / Refactoring
Testing /Acceptance
Done
![Page 39: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/39.jpg)
Let’s summarize
What is the gap and its fulfillment?
7
![Page 40: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/40.jpg)
Pyramid is betweenthe books
40© Copyright 2019 www.refactoring.pl
![Page 41: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/41.jpg)
Each SamplePlacement
41
SAMPLE
SAMPLE
SAMPLE
SAMPLE
SAMPLE
© Copyright 2019 www.refactoring.pl
![Page 42: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/42.jpg)
Each SampleEmbracement
42
EACHBIG
SAMPLE
© Copyright 2019 www.refactoring.pl
![Page 43: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/43.jpg)
43© Copyright 2019 www.refactoring.pl
… but joining core books!
Not named explicitly...
![Page 44: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/44.jpg)
44
Q & A© Copyright 2019 www.refactoring.pl
![Page 45: Refactoring Pyramid of - Java2Days](https://reader031.vdocuments.mx/reader031/viewer/2022012301/61e1fada20568316452afc63/html5/thumbnails/45.jpg)
45
Thanks!www.refactoring.pl
- Blog- IT Trainings- Talks
Włodek Krakowski@wlodekkr