Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Re-Architecting Applications (Without a Rewrite!)

Daniel Lew
February 10, 2018

Re-Architecting Applications (Without a Rewrite!)

Talk given at DevFestMN 2018 & MinneBar 13.

Recording here: https://youtu.be/dKm7MKoxVIg

Daniel Lew

February 10, 2018
Tweet

More Decks by Daniel Lew

Other Decks in Programming

Transcript

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

    View full-size slide

  2. architecture: the structure and
    design of a system or product

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  5. Danger
    • Pure architectures require fresh code

    • Rewrites always take longer than expected

    • Old code == battle tested

    • Expectations may not match reality

    View full-size slide

  6. Goals
    • Introduce new architectures to existing codebase

    • Push releases while re-architecting codebase

    View full-size slide

  7. Goal #1:
    Introduce new architectures to
    existing codebase

    View full-size slide

  8. Re-Architecting Safely
    • Prevent overly ambitious rewrites

    • Prevent regrettable architecture choices

    • Steps

    • Explore

    • Experiment

    • Expand

    • Embrace

    View full-size slide

  9. Explore
    • What is the problem?

    • Define goals

    • Define constraints

    • What are the solutions?

    • Brainstorm

    • Research

    View full-size slide

  10. Experiment
    • Pick a project

    • Minimize work

    • Small project

    • Simplified implementations

    • Minimize damage

    • Self-contained project

    • Unimportant project

    View full-size slide

  11. Expand
    • Run more experiments

    • Pick projects wisely

    • Use architecture in new ways

    • Pick hardest problems

    • Stretch architecture to limits

    View full-size slide

  12. Embrace
    • Write all new code with new architecture

    • Deprecate old architecture

    • Delete old code (optional)

    View full-size slide

  13. Disclaimer
    Not an exact science

    View full-size slide

  14. Goal #2:
    Push releases while re-architecting
    codebase

    View full-size slide

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

    View full-size slide

  16. Old
    New
    Old + New

    View full-size slide

  17. Parallel Development

    View full-size slide

  18. Decouple Code
    BAD GOOD

    View full-size slide

  19. Feature Flags

    View full-size slide

  20. Offline Mode
    A parallel development success story

    View full-size slide

  21. Online Only Offline Enabled

    View full-size slide

  22. Decoupling Services
    Before After

    View full-size slide

  23. Feature Flags

    View full-size slide

  24. Shims
    Before After

    View full-size slide

  25. 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/

    View full-size slide

  26. Failures
    With real life examples!

    View full-size slide

  27. Explore Failures
    • Architecting with no purpose

    • Navi

    • Choosing new and shiny without understanding

    • RxJava

    View full-size slide

  28. Experiment Failures
    • Making the experiment too large

    • JavaScript: The Good Parts

    • Not recognizing a failed experiment

    • Operations

    View full-size slide

  29. Expand Failures
    • Choosing only easy problems

    • Identifiers

    • Not recognizing a failed corner case

    • RxLifecycle

    View full-size slide

  30. Embrace Failures
    • Continuing to expend effort on old architecture

    • Fresh boards

    View full-size slide

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

    View full-size slide

  32. Current Architecture Thoughts

    View full-size slide

  33. Omni Models
    • Single model

    • Deserialized from JSON

    • Written to ORM

    • Used by UI

    • Problems

    • Which fields are present?

    • How do we avoid mutability issues?

    View full-size slide

  34. Domain-specific models
    • ApiModel

    • Only used when talking to server

    • DbModel

    • Mutable, flexible

    • UiModel

    • Immutable, guarantees values

    • ApiModel <-> DbModel <-> UiModel

    View full-size slide

  35. Unidirectional Architecture

    View full-size slide

  36. Thanks for listening!
    @danlew42

    View full-size slide