Refactoring for Software Architecture Smells - International Workshop on Refactoring - Sept 2016
Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the...
Transcript of Refactoring of Large Software Systems revised - … · Refactoring (noun): a change made to the...
Refactoring of Large Software Systems revised
Copyright Canoo Engineering AG, www.canoo.com 2
Sibylle Peter Sven Ehrke
Copyright Canoo Engineering AG, www.canoo.com 3
> Introduction
> The Case Study: Advisory Tool for Investment Bankers
> The Refactoring
> The Way We Work
> Lessons Learned
Introduction
Copyright Canoo Engineering AG, www.canoo.com 5
Definit ion (Mart in Fowler, Refactoring, pg. 53):
Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.
Refactor (verb): To restructure software by applying a series of refactorings without changing it ‘s observable behavior
Copyright Canoo Engineering AG, www.canoo.com 6
Copyright Canoo Engineering AG, www.canoo.com 7
Copyright Canoo Engineering AG, www.canoo.com 8
Copyright Canoo Engineering AG, www.canoo.com 9
Copyright Canoo Engineering AG, www.canoo.com 10
The Case Study
Copyright Canoo Engineering AG, www.canoo.com 12
Copyright Canoo Engineering AG, www.canoo.com 13
Facts
> Productive and successful since 2004
> Continuously expanded/ enlarged since then
> 320 JSP, 1800 classes
> Homegrown MVC framework, similar to Struts
> ca. 70 functional tests
> Few unit tests
> Little documentation
> High employee turnover
> High maintenance costs
> Change requests cannot be implemented
– complex ity
– Side effects
Copyright Canoo Engineering AG, www.canoo.com 14
Dependencies
Copyright Canoo Engineering AG, www.canoo.com 15
Original Situation
Action
Java Beans
JSP
ServiceInvoker
Service
Worker
Controller Helper
Mapper
Container
HttpServlet
BusinessObject
HttpServlet
Copyright Canoo Engineering AG, www.canoo.com 16
Action
Java Beans
JSP
Container
HttpServlet
BusinessObject
Facade TransferObject
HttpServlet
Util
Masterplan
Service Mapper
Copyright Canoo Engineering AG, www.canoo.com 17
Java Beans
Service Mapper
Validator
Facade TransferObject
Action
JSPHttpServlet
Masterplan
Formatter
AggregatingFacade
Standard GUIStandard GUITechnologyTechnology
(TBD)(TBD)
The RefactoringPart I – new service layer
Copyright Canoo Engineering AG, www.canoo.com 19
Service Layer Architecture
Presentation Layer
ServiceLayer
aggregation
Facade 1 Facade 2 Facade 3 Facade 4
WS DB Host
Facade 2Facade 1
Serv
icel
ayer
.uti
l
Copyright Canoo Engineering AG, www.canoo.com 20
Step 1: Structuring through Facades
Copyright Canoo Engineering AG, www.canoo.com 21
Step 2: Introducing Transfer Objects
Copyright Canoo Engineering AG, www.canoo.com 22
PresentationLayer
transfer objects
JSP Java Bean Action HttpRequest
BusinessObjectConverter
TransferObject
Facade
Service
ServiceLayer
Copyright Canoo Engineering AG, www.canoo.com 23
Copyright Canoo Engineering AG, www.canoo.com 24
Copyright Canoo Engineering AG, www.canoo.com 25
Facade Interface
Copyright Canoo Engineering AG, www.canoo.com 26
PresentationLayerJSP Java Bean Action HttpRequest
BusinessObject Converter
TransferObject ServiceLayer
ServiceObject
EJB Proxy
simple
complex
1:1
1:n Mapper
Copyright Canoo Engineering AG, www.canoo.com 27
PresentationLayerJSP Java Bean Action HttpRequest
BusinessObject Converter
TransferObject ServiceLayer
ServiceObject
EJB Proxy
simple
complex
m:n
1:1 Mapper
Copyright Canoo Engineering AG, www.canoo.com 28
Step 3: New Service Layer
inTO outTO
Service
Copyright Canoo Engineering AG, www.canoo.com 29
Service Interface
Copyright Canoo Engineering AG, www.canoo.com 30
Step 3: New Service Layer
inTO outTO
Service
outSOinSO
EJB Method
Mapper Mapper
Copyright Canoo Engineering AG, www.canoo.com 31
AbstractService
Copyright Canoo Engineering AG, www.canoo.com 32
Copyright Canoo Engineering AG, www.canoo.com 33
inTO outTO
Services
inTO A outTO A
Service A
Service
inTO B outTO B
Service B
Copyright Canoo Engineering AG, www.canoo.com 34
Copyright Canoo Engineering AG, www.canoo.com 35
Step 4: Introducing Basetypes
Copyright Canoo Engineering AG, www.canoo.com 36
Facade Interface
The Way We Work
Copyright Canoo Engineering AG, www.canoo.com 38
Daily Work
Copyright Canoo Engineering AG, www.canoo.com 39
Coordination
Daily standup meeting
Regular workshops with the customer‘s lead engineer
retrospective after each
refactoring step
Lightweigth, but intensive
testing process with test team
Monthly meeting with
the project manager of the
customer
Weekly reporting with
the lead engineer and
team lead of the customer
Copyright Canoo Engineering AG, www.canoo.com 40
Without changing it’s observable behavior
Functional tests
> 50% code coverage
Continuous integration
> No build server - > installed teamcity on a spare machine
> Nightly build incl. Webtests
Testing
> Functional tests require host services stubs will be created in part 2> Complete test of the application takes 3 weeks Tester integrated in our team for testing phase. > Nightly deployment on test server> Tester created videos (for us and to create more automated tests)
Lessons Learned
Copyright Canoo Engineering AG, www.canoo.com 41
Copyright Canoo Engineering AG, www.canoo.com 42Le
sso
ns
lear
ned
> Knowledge transfer to the core team as early as possible
> Continous integration is a must
> Investment in automated test suite
> Dependencies to other systems
> Automated quality assurance
> Testing phase much longer than anticipated
> Focus on technical refactoring can be lifesaving
> Refactoring of a large software system is a new project
> KISS: Simplicity is needed
Copyright Canoo Engineering AG, www.canoo.com 43A
chie
vem
ents
> Costs per feature reduced
> Service oriented architecture
> Side effects removed
> Separation between layers and modules
> Automated quality assurance
> Long required new functionality which served as key differentiator has been implemented
Copyright Canoo Engineering AG, www.canoo.com 44
Refactoring Benefits
Copyright Canoo Engineering AG, www.canoo.com 45
Refactoring of Large Software Systems is
Copyright Canoo Engineering AG, www.canoo.com 46
Refactoring of Large Software Systems needs
Books
• Martin Fowler, Refactoring: Improving the Design of Existing Code
• Stephan Ducasse, Oscar Nierstrasz, Object Oriented Reengineering Patterns PDF: http:/ / www.win.ua.ac.be/ ~sdemey/
•
Joshua Kerievsky, Refactoring to Patterns•
Martin Lippert, Stefan Rook, Refactoring in Large Software Projects
Copyright Canoo Engineering AG, www.canoo.com 47
Questions?