Slide 1

Slide 1 text

Re-architecting Applications (Without a Rewrite!) @danlew42

Slide 2

Slide 2 text

architecture: the structure and design of a system or product

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

“Model-View- Controller is the best thing since sliced bread.” ~Evil Dan Lew

Slide 9

Slide 9 text

“OMG, I’m switching to MVC ASAP!” ~You Stability Some New Architecture

Slide 10

Slide 10 text

Danger • Pure architectures require fresh code • Rewrites always take longer than expected • Old code == battle tested • Expectations may not match reality

Slide 11

Slide 11 text

Goals • Introduce new architectures to existing codebase • Push releases while re-architecting codebase

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Slide 14

Slide 14 text

Goal #1: Introduce new architectures to existing codebase

Slide 15

Slide 15 text

Re-Architecting Safely • Prevent overly ambitious rewrites • Prevent regrettable architecture choices • Steps • Explore • Experiment • Expand • Embrace

Slide 16

Slide 16 text

Explore • What is the problem? • Define goals • Define constraints • What are the solutions? • Brainstorm • Research

Slide 17

Slide 17 text

Experiment • Pick a project • Minimize work • Small project • Simplified implementations • Minimize damage • Self-contained project • Unimportant project

Slide 18

Slide 18 text

Expand • Run more experiments • Pick projects wisely • Use architecture in new ways • Pick hardest problems • Stretch architecture to limits

Slide 19

Slide 19 text

Embrace • Write all new code with new architecture • Deprecate old architecture • Delete old code (optional)

Slide 20

Slide 20 text

Disclaimer Not an exact science

Slide 21

Slide 21 text

Goal #2: Push releases while re-architecting codebase

Slide 22

Slide 22 text

Can’t simultaneously use old and new architecture Can’t keep releasing

Slide 23

Slide 23 text

Old New Old + New

Slide 24

Slide 24 text

Parallel Development

Slide 25

Slide 25 text

Decouple Code BAD GOOD

Slide 26

Slide 26 text

Feature Flags

Slide 27

Slide 27 text

Shims

Slide 28

Slide 28 text

Shims

Slide 29

Slide 29 text

Offline Mode A parallel development success story

Slide 30

Slide 30 text

Online Only Offline Enabled

Slide 31

Slide 31 text

Decoupling Services Before After

Slide 32

Slide 32 text

Feature Flags

Slide 33

Slide 33 text

Shims Before After

Slide 34

Slide 34 text

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/

Slide 35

Slide 35 text

Failures With real life examples!

Slide 36

Slide 36 text

Explore Failures • Architecting with no purpose • Navi • Choosing new and shiny without understanding • RxJava

Slide 37

Slide 37 text

Experiment Failures • Making the experiment too large • JavaScript: The Good Parts • Not recognizing a failed experiment • Operations

Slide 38

Slide 38 text

Expand Failures • Choosing only easy problems • Identifiers • Not recognizing a failed corner case • RxLifecycle

Slide 39

Slide 39 text

Embrace Failures • Continuing to expend effort on old architecture • Fresh boards

Slide 40

Slide 40 text

Pet Peeve Telling everyone about an architecture before proving it out!

Slide 41

Slide 41 text

Current Architecture Thoughts

Slide 42

Slide 42 text

Omni Models • Single model • Deserialized from JSON • Written to ORM • Used by UI • Problems • Which fields are present? • How do we avoid mutability issues?

Slide 43

Slide 43 text

Domain-specific models • ApiModel • Only used when talking to server • DbModel • Mutable, flexible • UiModel • Immutable, guarantees values • ApiModel <-> DbModel <-> UiModel

Slide 44

Slide 44 text

Unidirectional Architecture

Slide 45

Slide 45 text

Thanks for listening! @danlew42