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

The Good Architecture

The Good Architecture

Krzysztof Wawer

November 20, 2019
Tweet

More Decks by Krzysztof Wawer

Other Decks in Programming

Transcript

  1. The Good
    Architecture

    View Slide

  2. Krzysztof Wawer
    Github: wafcio
    Twitter: @wafcio

    View Slide

  3. 1. Principles

    2. Architectures

    View Slide

  4. Principles

    View Slide

  5. Principles
    • DRY

    View Slide

  6. Principles
    • DRY

    • KISS

    View Slide

  7. Principles
    • DRY

    • KISS

    • SOLID

    View Slide

  8. Principles
    • DRY

    • KISS

    • SOLID

    • YAGNI

    View Slide

  9. DRY
    “Don’t Repeat Yourself”
    Andrew Hunt and David Thomas,
    October 1999,
    The Pragmatic Bookshelf

    View Slide

  10. DRY
    extras
    extras_allowed?(shop, invoice, order)




    … …




    View Slide

  11. KISS
    “Keep it simple, stupid”
    “Keep it stupid simple”
    U.S. Navy in 1960,
    aircraft engineer Kelly Johnson

    View Slide

  12. KISS

    View Slide

  13. < = >
    LESS IS MORE

    View Slide

  14. SOLID
    • SRP (Single Responsible Principle)

    • OCP (Open/Closed Principle)

    • LSP (Liskov Substitution Principle)

    • ISP (Interface Segregation Principle)

    • DIP (Dependency Inversion Principle)
    Robert C. Martin
    (Uncle Bob)

    View Slide

  15. SRP
    Single Responsible Principle
    • 2002

    • A class should have
    one, and only one,
    reason to change
    http://rubyblog.pro/2017/05/solid-single-responsibility-principle-by-example

    View Slide

  16. SRP
    Single Responsible Principle

    View Slide

  17. Contexts

    View Slide

  18. OCP
    Open/Closed Principle
    • 1996

    • You should be able
    to extend a classes
    behavior, without
    modifying it
    http://rubyblog.pro/2017/05/solid-open-closed-principle-by-example

    View Slide

  19. LSP
    Liskov Substitution Principle
    • 1987

    • Barbara Liskov

    • Let Φ(x) be a property provable about objects x of type
    T. Then Φ(y) should be true for objects y of type S
    where S is a subtype of T.
    http://rubyblog.pro/2017/06/solid-liskov-substitution-principle

    View Slide

  20. LSP
    Liskov Substitution Principle
    • objects in a program
    should be
    replaceable with
    instances of their
    subtypes without
    altering the
    correctness of that
    program
    http://rubyblog.pro/2017/06/solid-liskov-substitution-principle

    View Slide

  21. LSP anti-pattern

    View Slide

  22. ISP
    Interface Segregation Principle
    • 1996

    • Clients should not
    be forced to depend
    upon interfaces that
    they don't use.
    http://rubyblog.pro/2017/07/solid-interface-segregation-principle

    View Slide

  23. DIP
    Dependency Inversion Principle
    • 1996

    • High-level modules should
    not depend on low-level
    modules. Both should
    depend on abstractions

    • Abstractions should not
    depend on details. Details
    should depend on
    abstractions.
    http://rubyblog.pro/2017/07/solid-dependency-inversion-principle

    View Slide

  24. SOLID
    Robert C. Martin
    (Uncle Bob)

    View Slide

  25. YAGNI
    You aren't gonna need it
    • principle of extreme
    programming (XP)

    • XP co-founder Ron
    Jeffries has written:
    "Always implement
    things when you
    actually need them,
    never when you just
    foresee that you
    need them."

    View Slide

  26. Architectures

    View Slide

  27. Software Architecture
    Chronicles 2000s
    • 2003 - Domain Driven Design

    • 2005 - Ports & Adapters Architecture aka Hexagonal Architecture

    • ~2006 - CQRS & ES (Event Sourcing)

    • 2008 - Onion Architecture

    • 2012 - Clean Architecture

    View Slide

  28. Domain Driven Design

    View Slide

  29. Domain Driven Design

    View Slide

  30. Software Architecture
    Chronicles 2000s
    • 2003 - Domain Driven Design

    • 2005 - Ports & Adapters Architecture aka Hexagonal Architecture

    • ~2006 - CQRS & ES (Event Sourcing)

    • 2008 - Onion Architecture

    • 2012 - Clean Architecture

    View Slide

  31. Hexagonal Architecture

    View Slide

  32. Hexagonal Architecture

    View Slide

  33. Hexagonal Architecture

    View Slide

  34. Hexagonal Architecture

    View Slide

  35. Hexagonal Architecture

    View Slide

  36. Hexagonal Architecture

    View Slide

  37. Hexagonal Architecture

    View Slide

  38. Hexagonal Architecture

    View Slide

  39. Hexagonal Architecture

    View Slide

  40. Hexagonal Architecture

    View Slide

  41. Software Architecture
    Chronicles 2000s
    • 2003 - Domain Driven Design

    • 2005 - Ports & Adapters Architecture aka Hexagonal Architecture

    • ~2006 - CQRS & ES (Event Sourcing)

    • 2008 - Onion Architecture

    • 2012 - Clean Architecture

    View Slide

  42. CQS
    Command Query Separation
    • devised by Bertrand Meyer during his work on the Eiffel
    programming language

    • Queries: Return a result and do not change the observable state
    of the system (are free of side effects)

    • Commands: Change the state of a system but do not return a
    value

    View Slide

  43. Command Query
    Responsible Segregation
    2006 Greg Young describes CQRS

    View Slide

  44. Command Query
    Responsible Segregation

    View Slide

  45. Command Query
    Responsible Segregation

    View Slide

  46. Software Architecture
    Chronicles 2000s
    • 2002 - SRP (SOLID)

    • 2003 - Domain Driven Design

    • 2005 - Ports & Adapters Architecture aka Hexagonal Architecture

    • ~2006 - CQRS & ES (Event Sourcing)

    • 2008 - Onion Architecture

    • 2012 - Clean Architecture

    View Slide

  47. Event-Driven Architecture
    • Event Notification (Event Bus)

    • Event Sourcing (Event Store)

    View Slide

  48. Event-Driven Architecture

    View Slide

  49. Event Sourcing

    View Slide

  50. Software Architecture
    Chronicles 2000s
    • 2002 - SRP (SOLID)

    • 2003 - Domain Driven Design

    • 2005 - Ports & Adapters Architecture aka Hexagonal Architecture

    • ~2006 - CQRS & ES (Event Sourcing)

    • 2008 - Onion Architecture

    • 2012 - Clean Architecture

    View Slide

  51. Onion Architecture
    https://herbertograca.com/2017/09/21/onion-architecture/

    View Slide

  52. Software Architecture
    Chronicles 2000s
    • 2002 - SRP (SOLID)

    • 2003 - Domain Driven Design

    • 2005 - Ports & Adapters Architecture aka Hexagonal Architecture

    • ~2006 - CQRS & ES (Event Sourcing)

    • 2008 - Onion Architecture

    • 2012 - Clean Architecture

    View Slide

  53. Clean Architecture
    https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html

    View Slide

  54. No architecture

    View Slide

  55. @herbertograca
    • https://herbertograca.com

    • The Software Architecture Chronicles

    • The Containerization Chronicles

    • Domain Driven Design

    • Lean Architecture

    • Patterns of Enterprise Application Architecture

    • Patterns Principles and Practices of Domain-Driven Design

    • The mythical man-month

    View Slide

  56. Q & A

    View Slide