big rewrites without big risks
TRANSCRIPT
Big rewrites without big risksFlavius Ștef
https://flic.kr/p/9iuMzn
About meI train and coachpeople in agile, lean
and leadership
Iterative and incremental
Images: http://www.yoomee.com/about-agile
Why?
time
risk
time
risk
validate
validate validate validate validate
New skill: story splitting
● Create-Read-Update-Delete● Workflow steps● Less usability first● etc.
xx x
x
x
x x
x x x
Splittingfeaturesis easy
THE PROBLEM OFTHE PROBLEM OFINCREMENTAL REFACTORINGINCREMENTAL REFACTORING
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)
IncrementalIncrementalArchitectureArchitectureRefactoring?Refactoring?
Agile doesn't apply here!!!
But the questions remain
How do we knowthe app still works?
How do we know how much is done?
How do we knowwhen we'll finish?
STRATEGIESSTRATEGIES
Sorry, stillno silver bullet
Get creative!Get creative!
1. Fake it till you make it
Product 1Desktop (C#)Windows
Product 2 ~ Product 1Desktop (C#)Windows
Product 3Desktop (C#)Windows
Front-end platformJava, JS
AwesomeNextGen Product
Linux-basedWeb UI (Java, JS)
GUI(C#)
Middleware(C#)
RPC HardwareManager
(C++)Packet
Generators
RPC
Old Product
WIN CLIENT TRAFFIC GENERATOR
GUI(C#)
Middleware(C#)
RPC HardwareManager
(C++)Packet
Generators
RPC
Step 1. Research (1 Sprint)
TRAFFIC GENERATOR
GUI(C#)
Middleware(C#)
RPC HardwareManager
(C++)Packet
Generators
RPC
TRAFFIC GENERATOR
GUI(C#)
Middleware(C#)
RPC HardwareManager
(C++)Packet
Generators
RPC
TRAFFIC GENERATOR
WIN CLIENT
WIN CLIENT
WIN CLIENT
Step 2. Make MW run on Linux (2 Sprints)
Middleware(C#)
LINUX CLIENT
Mono
WebUI
Step 3. Link web UI with middleware (1 week)
Middleware(C#)
LINUX CLIENT
Mono
WebUI Send basic message between the two.
Step 3. Link web UI with middleware (1 week)
Middleware(C#)
LINUX CLIENT
Mono
WebUI
C# bindingsexist
PROBLEM:Java bindingsdon't exist
RPCexpected
Step 4. Walking skeleton (2 days)
Middleware(C#)
LINUX CLIENT
Mono
WebUI
Old MW(C#)
Configuredifferentscenarios Dump to disk
Hack: load dump
HardwareManager
(C++)Packet
Generators
RPC
TRAFFIC GENERATOR
x
Start
Conf. #: 3
Google Chrome
OK!
Step 4. Walking skeleton (2 days)
Middleware(C#)
LINUX CLIENT
Mono
WebUI
RPC
Old MW(C#)
Configuredifferentscenarios Dump to disk
Hack: load dump
HardwareManager
(C++)Packet
Generators
RPC
TRAFFIC GENERATORx
Start
Conf. #: 3
Google Chrome
Step 5. Read+write configuration (3 weeks)
Middleware(C#)
LINUX CLIENT
Mono
WebUI
RPCHardwareManager
(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 #4Write: Add a machine to configurationRead: Another statistic...
BACKLOG
Timeline
Research
Make it run on Linux
WalkingSkeleton
Stories for demo version10d
20d
7d
15d
About 1 month
2. I just don't love you anymorehttps://flic.kr/p/rrHjG
Same product, different team
Middleware(C#)
Mono
WebUI
RPCHardwareManager
(C++)Packet
Generators
RPC
TRAFFIC GENERATORLINUX CLIENT
Step 1. Analyze dependencies & possible replacements (2 Weeks)
HardwareManager
(C++)
MFC WinAPI
STL Boost
Find substitutes
Step 2. Proof of concept (2 Months)
HardwareManager
(C++)
MFC WinAPI
Hack alternatives for:- (De)Serialization (MFC)- IPC (WinAPI)- …
STL Boost
CString → CMyStringCArray → CMyArray
Step 2. Proof of concept (2 Months)
“Hacked”HardwareManager
STL Boost
PacketGenerators
#ifdef __vm
Implemented ~1% of use cases- Select only one HW card- Comment out other code
Step 3. Unit testing (2 Weeks)
CString sut = “foo”; CMyString sut = “foo”;
StringTestvalidateagainst
validateagainst
Step 4. Performance testing (2 Weeks)
CFile sut; CMyFile sut;
StringPerformanceTest
validateagainst
validateagainst
for (i=0; i<20000; i++)
CFile (MFC) 20x faster than CMyFile (Boost)
Step 5. Incrementally remove Win dependency
2m 2m 1m
Remove MFC Remove WinAPI Finaltesting
Windows Linux
Process
TRUNK
DEV
...1w
Run
tes
tsR
un t
ests
3d
CodeFreezePractices:
● Software buildable and running at all times● Pull weekly from trunk● Run regression (10.000+ tests) every 3 days● Continuous integration (team level)
3. One bite at a time
https://flic.kr/p/CaNo1
Rewrite #1
4m 7m
Rewrite #2 BetaLaunch
An interface rewrite
2m
Abort!
Rally:circa 2008
Rally:circa 2009
What about the stories
page?
Oh, there were
changes...
4. Rewrite the story book
Three Amigos
Dev QA BA
Feature: ________
Scenario:________
Given ________When ________Then _________
Scenarios
PROCESSPROCESS
Set goalAnalyze
architectureCreatebacklog
Talk to QA
Pickrefactoring
RefactorTest
Update backlog
Stop
Done?
YES
Integrate
NO
Add testsif needed
Analyzearchitecture
Createbacklog
Talk to QA
PickrefactoringRefactorTest
Update backlog
Stop
Done?
YES
Integrate
NO
Add testsif needed
Business“Switch database vendors”“Implement new features faster”
Or Technical“Support 3000 concurrent connections”“Centralize security controls”
Set goal
Set goalCreatebacklog
Talk to QA
PickrefactoringRefactorTest
Update backlog
Stop
Done?
YES
Integrate
NO
Add testsif needed
SWOT Analysis(Strengths, Weaknesses, Opportunities, Threats)- What do we keep?- What do we drop?- What do we improve?
Analyzearchitecture
Analyzearchitecture
Set goal Talk to QA
PickrefactoringRefactorTest
Update backlog
Stop
Done?
YES
Integrate
NO
Add testsif needed
Architecture Epics“Remove MFC”
“Move DB code from JSPs”
Createbacklog
Createbacklog
Analyzearchitecture
Set goal
PickrefactoringRefactorTest
Update backlog
Stop
Done?
YES
Integrate
NO
Add testsif needed
What is the testing strategy?Automation vs. exploratory
How oftenMake sure testers are available
Talk to QA
Stop
YES
Talk to QACreatebacklog
Analyzearchitecture
Set goal
PickrefactoringRefactorTest
Update backlog
Done?
Integrate
NO
Add testsif needed
Mikado Method
Goal
Prerequisite Prerequisite
Prerequisite Prerequisite Prerequisite
The Mikado Method
Mikado Method
Move servicefrom Windows
to Linux
Fix Win APIcompiler errs
Fix MFCcompiler errs
Fix CStringcompiler errs
WriteCMyString
Replace CStringinvocations
If you need some guidance selecting the refactoring
http://www.sigs.de/download/oop_08/Stal%20Mi3-4.pdf+ Michael Stal: Architecture Refactoring Catalog
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
CONCLUSIONCONCLUSION
It's hard, but it can be done
Chunk the problem down
Encapsulate, stub, simulate
Work incrementally
Run tests
Validate against the goal
SUMMARY
THANKS!
Flavius Ștef
Twitter: @flaviusstefSlides: slideshare.net/fstef
www.mozaicworks.com/blog/