Re-Architecting Applications (Without a Rewrite!)

D225ebf0faa666ac7655cc7e4689283c?s=47 Daniel Lew
February 10, 2018

Re-Architecting Applications (Without a Rewrite!)

Talk given at DevFestMN 2018 & MinneBar 13.

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

D225ebf0faa666ac7655cc7e4689283c?s=128

Daniel Lew

February 10, 2018
Tweet

Transcript

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

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

  3. None
  4. None
  5. None
  6. None
  7. None
  8. “Model-View- Controller is the best thing since sliced bread.” ~Evil

    Dan Lew
  9. “OMG, I’m switching to MVC ASAP!” ~You Stability Some New

    Architecture
  10. Danger • Pure architectures require fresh code • Rewrites always

    take longer than expected • Old code == battle tested • Expectations may not match reality
  11. Goals • Introduce new architectures to existing codebase • Push

    releases while re-architecting codebase
  12. None
  13. </Housing Metaphors>

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

  15. Re-Architecting Safely • Prevent overly ambitious rewrites • Prevent regrettable

    architecture choices • Steps • Explore • Experiment • Expand • Embrace
  16. Explore • What is the problem? • Define goals •

    Define constraints • What are the solutions? • Brainstorm • Research
  17. Experiment • Pick a project • Minimize work • Small

    project • Simplified implementations • Minimize damage • Self-contained project • Unimportant project
  18. Expand • Run more experiments • Pick projects wisely •

    Use architecture in new ways • Pick hardest problems • Stretch architecture to limits
  19. Embrace • Write all new code with new architecture •

    Deprecate old architecture • Delete old code (optional)
  20. Disclaimer Not an exact science

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

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

  23. Old New Old + New

  24. Parallel Development

  25. Decouple Code BAD GOOD

  26. Feature Flags

  27. Shims

  28. Shims

  29. Offline Mode A parallel development success story

  30. Online Only Offline Enabled

  31. Decoupling Services Before After

  32. Feature Flags

  33. Shims Before After

  34. 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/
  35. Failures With real life examples!

  36. Explore Failures • Architecting with no purpose • Navi •

    Choosing new and shiny without understanding • RxJava
  37. Experiment Failures • Making the experiment too large • JavaScript:

    The Good Parts • Not recognizing a failed experiment • Operations
  38. Expand Failures • Choosing only easy problems • Identifiers •

    Not recognizing a failed corner case • RxLifecycle
  39. Embrace Failures • Continuing to expend effort on old architecture

    • Fresh boards
  40. Pet Peeve Telling everyone about an architecture before proving it

    out!
  41. Current Architecture Thoughts

  42. Omni Models • Single model • Deserialized from JSON •

    Written to ORM • Used by UI • Problems • Which fields are present? • How do we avoid mutability issues?
  43. Domain-specific models • ApiModel • Only used when talking to

    server • DbModel • Mutable, flexible • UiModel • Immutable, guarantees values • ApiModel <-> DbModel <-> UiModel
  44. Unidirectional Architecture

  45. Thanks for listening! @danlew42