7. THE PROBLEM OFTHE PROBLEM OF
INCREMENTAL REFACTORINGINCREMENTAL REFACTORING
8. Sometimes we need a new architecture
●
Go faster
●
Reduce number of bugs
●
Improve an NFR
●
Respond to client demands
●
Respond to market (ex: cloud, mobile, web)
18. Step 2. Make MW run on Linux (2 Sprints)
Middleware
(C#)
LINUX CLIENT
Mono
Web
UI
19. Step 3. Link web UI with middleware (1 week)
Middleware
(C#)
LINUX CLIENT
Mono
Web
UI Send basic message between the two.
20. Step 3. Link web UI with middleware (1 week)
Middleware
(C#)
LINUX CLIENT
Mono
Web
UI
C# bindings
exist
PROBLEM:
Java bindings
don't exist
RPC
expected
21. Step 4. Walking skeleton (2 days)
Middleware
(C#)
LINUX CLIENT
Mono
Web
UI
Old MW
(C#)
Configure
different
scenarios Dump to disk
Hack: load dump
Hardware
Manager
(C++)
Packet
Generators
RPC
TRAFFIC GENERATOR
x
Start
Conf. #: 3
Google Chrome
OK!
22. Step 4. Walking skeleton (2 days)
Middleware
(C#)
LINUX CLIENT
Mono
Web
UI
RPC
Old MW
(C#)
Configure
different
scenarios Dump to disk
Hack: load dump
Hardware
Manager
(C++)
Packet
Generators
RPC
TRAFFIC GENERATOR
x
Start
Conf. #: 3
Google Chrome
23. Step 5. Read+write configuration (3 weeks)
Middleware
(C#)
LINUX CLIENT
Mono
Web
UI
RPC
Hardware
Manager
(C++)
Packet
Generators
RPC
TRAFFIC GENERATOR
RPC endpoint in C# existed in old product.
New product built Java RPC incrementally.
Read: How many NICs in the configuration?
Read: What are their Ips?
Write: Set IP of NIC #4
Write: Add a machine to configuration
Read: Another statistic
...
B
A
C
K
L
O
G
29. Step 2. Proof of concept (2 Months)
“Hacked”
Hardware
Manager
STL Boost
Packet
Generators
#ifdef __vm
Implemented ~1% of use cases
- Select only one HW card
- Comment out other code
30. Step 3. Unit testing (2 Weeks)
CString sut = “foo”; CMyString sut = “foo”;
StringTestvalidate
against
validate
against
31. Step 4. Performance testing (2 Weeks)
CFile sut; CMyFile sut;
StringPerformanceTest
validate
against
validate
against
for (i=0; i<20000; i++)
CFile (MFC) 20x faster
than CMyFile (Boost)
32. Step 5. Incrementally remove Win dependency
2m 2m 1m
Remove MFC Remove WinAPI Final
testing
Windows Linux
45. Set goal
Create
backlog
Talk to QA
Pick
refactoring
RefactorTest
Update
backlog
Stop
Done?
YES
Integrate
NO
Add tests
if needed
SWOT Analysis
(Strengths, Weaknesses,
Opportunities, Threats)
- What do we keep?
- What do we drop?
- What do we improve?
Analyze
architecture
46. Analyze
architecture
Set goal Talk to QA
Pick
refactoring
RefactorTest
Update
backlog
Stop
Done?
YES
Integrate
NO
Add tests
if needed
Architecture Epics
“Remove MFC”
“Move DB code from JSPs”
Create
backlog
50. Mikado Method
Move service
from Windows
to Linux
Fix Win API
compiler errs
Fix MFC
compiler errs
Fix CString
compiler errs
Write
CMyString
Replace CString
invocations
51. If you need some guidance selecting the
refactoring
http://www.sigs.de/download/oop_08/Stal%20Mi3-4.pdf+ Michael Stal: Architecture Refactoring Catalog
52. Michael Stal: source of architecture refactorings
●
Rename Entities
●
Remove Duplicates
●
Introduce Abstraction
Hierarchies
●
Remove Unnecessary
Abstractions
●
Substitute Mediation with
Adaptation
●
Break Dependency Cycles
●
Inject Dependencies
●
Insert Transparency Layer
●
Reduce Dependencies with
Facades
●
Merge Subsystems
●
Split Subsystems
●
Enforce Strict Layering
●
Move Entities
●
Add Strategies
●
Enforce Symmetry
●
Extract Interface
●
Enforce Contract
●
Provide Extension
Interfaces
●
Substitute Inheritance with
Delegation
●
Provide Interoperability
Layers
●
Aspectify
●
Integrate DSLs
●
Add Uniform Supp. to
Runtime Aspects
●
Add Configuration Subsystem
●
Introduce the Open/Close
Principle
●
Optimize with Caching
●
Replace Singleton
●
Separate Synchronous and
Asynchronous Processing
●
Replace Remote Methods
with Messages
●
Add Object Manager
●
Change Unidirectional
Association to Bidirectional