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 full-size slide

  2. Krzysztof Wawer
    Github: wafcio
    Twitter: @wafcio

    View full-size slide

  3. 1. Principles

    2. Architectures

    View full-size slide

  4. Principles
    • DRY

    View full-size slide

  5. Principles
    • DRY

    • KISS

    View full-size slide

  6. Principles
    • DRY

    • KISS

    • SOLID

    View full-size slide

  7. Principles
    • DRY

    • KISS

    • SOLID

    • YAGNI

    View full-size slide

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

    View full-size slide

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




    … …




    View full-size slide

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

    View full-size slide

  11. < = >
    LESS IS MORE

    View full-size slide

  12. 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 full-size slide

  13. 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 full-size slide

  14. SRP
    Single Responsible Principle

    View full-size slide

  15. 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 full-size slide

  16. 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 full-size slide

  17. 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 full-size slide

  18. LSP anti-pattern

    View full-size slide

  19. 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 full-size slide

  20. 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 full-size slide

  21. SOLID
    Robert C. Martin
    (Uncle Bob)

    View full-size slide

  22. 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 full-size slide

  23. Architectures

    View full-size slide

  24. 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 full-size slide

  25. Domain Driven Design

    View full-size slide

  26. Domain Driven Design

    View full-size 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 full-size slide

  28. Hexagonal Architecture

    View full-size slide

  29. Hexagonal Architecture

    View full-size slide

  30. Hexagonal Architecture

    View full-size slide

  31. Hexagonal Architecture

    View full-size slide

  32. Hexagonal Architecture

    View full-size slide

  33. Hexagonal Architecture

    View full-size slide

  34. Hexagonal Architecture

    View full-size slide

  35. Hexagonal Architecture

    View full-size slide

  36. Hexagonal Architecture

    View full-size slide

  37. Hexagonal Architecture

    View full-size slide

  38. 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 full-size slide

  39. 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 full-size slide

  40. Command Query
    Responsible Segregation
    2006 Greg Young describes CQRS

    View full-size slide

  41. Command Query
    Responsible Segregation

    View full-size slide

  42. Command Query
    Responsible Segregation

    View full-size slide

  43. 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 full-size slide

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

    • Event Sourcing (Event Store)

    View full-size slide

  45. Event-Driven Architecture

    View full-size slide

  46. Event Sourcing

    View full-size slide

  47. 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 full-size slide

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

    View full-size slide

  49. 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 full-size slide

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

    View full-size slide

  51. No architecture

    View full-size slide

  52. @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 full-size slide