Talk given at DevFestMN 2018 & MinneBar 13.
Recording here: https://youtu.be/dKm7MKoxVIg
Re-architecting Applications (Without a Rewrite!)@danlew42
View Slide
architecture: the structure anddesign of a system or product
“Model-View-Controller is thebest thing sincesliced bread.”~Evil Dan Lew
“OMG, I’mswitching to MVCASAP!”~YouStabilitySome NewArchitecture
Danger• Pure architectures require fresh code• Rewrites always take longer than expected• Old code == battle tested• Expectations may not match reality
Goals• Introduce new architectures to existing codebase• Push releases while re-architecting codebase
Goal #1:Introduce new architectures toexisting codebase
Re-Architecting Safely• Prevent overly ambitious rewrites• Prevent regrettable architecture choices• Steps• Explore• Experiment• Expand• Embrace
Explore• What is the problem?• Define goals• Define constraints• What are the solutions?• Brainstorm• Research
Experiment• Pick a project• Minimize work• Small project• Simplified implementations• Minimize damage• Self-contained project• Unimportant project
Expand• Run more experiments• Pick projects wisely• Use architecture in new ways• Pick hardest problems• Stretch architecture to limits
Embrace• Write all new code with new architecture• Deprecate old architecture• Delete old code (optional)
DisclaimerNot an exact science
Goal #2:Push releases while re-architectingcodebase
Can’t simultaneously use oldand new architectureCan’t keep releasing
OldNewOld + New
Parallel Development
Decouple CodeBAD GOOD
Feature Flags
Shims
Offline ModeA parallel development success story
Online Only Offline Enabled
Decoupling ServicesBefore After
ShimsBefore After
Offline Mode• Project length: 1.5 years• Never stopped releasing• Minimal UI changes• Gradual experimentation via flags• Switched over without anyone noticing• https://tech.trello.com/sync-architecture/
FailuresWith real life examples!
Explore Failures• Architecting with no purpose• Navi• Choosing new and shiny without understanding• RxJava
Experiment Failures• Making the experiment too large• JavaScript: The Good Parts• Not recognizing a failed experiment• Operations
Expand Failures• Choosing only easy problems• Identifiers• Not recognizing a failed corner case• RxLifecycle
Embrace Failures• Continuing to expend effort on old architecture• Fresh boards
Pet PeeveTelling everyone about an architecturebefore proving it out!
Current Architecture Thoughts
Omni Models• Single model• Deserialized from JSON• Written to ORM• Used by UI• Problems• Which fields are present?• How do we avoid mutability issues?
Domain-specific models• ApiModel• Only used when talking to server• DbModel• Mutable, flexible• UiModel• Immutable, guarantees values• ApiModel <-> DbModel <-> UiModel
Unidirectional Architecture
Thanks for listening!@danlew42