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

Introduction to Clean Architecture - CaquiCoders

Introduction to Clean Architecture - CaquiCoders

Ivan Paulovich

June 29, 2020
Tweet

More Decks by Ivan Paulovich

Other Decks in Programming

Transcript

  1. Each of these architectures produce systems that are: • Independent

    of Frameworks. • Testable. • Independent of UI. • Independent of Database. • Independent of any external agency. https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html “ @ivanpaulovich
  2. Clean Architecture Style @ivanpaulovich Clean Architecture Style Hexagonal Architecture Style

    Ports and Adapters Pattern Dependency Inversion
 Principle Test-Driven Development Clean Architecture Style @ivanpaulovich
  3. Clean Architecture Style Hexagonal Architecture Style Ports and Adapters Pattern

    Dependency Inversion
 Principle Test-Driven Development Clean Architecture Style Object-Oriented Design
 Principles Use Cases as Central Organizing Structure Pluggable User Interface @ivanpaulovich
  4. Hexagonal Architecture Style •Ports and Adapters pattern. •The implementation is

    guided by tests. •It is decoupled from technology details. @ivanpaulovich
  5. Business @ivanpaulovich 11 Ports and Adapters Cloud Messaging UI In

    Memory Persistence Tests In Memory Messaging SQL
  6. Business @ivanpaulovich 12 Ports and Adapters Cloud Messaging UI In

    Memory Persistence Tests In Memory Messaging SQL Ports
  7. Business v @ivanpaulovich 14 Ports and Adapters Cloud Messaging UI

    In Memory Persistence Tests In Memory Messaging SQL Adapters
  8. Application Unit Test Web Database Domain Primary Actors Secondary Actors

    @ivanpaulovich 16 Infrastructure Ports and Adapters
  9. Use Cases • Use Cases show the intent of a

    system. • Use Cases are delivery independent. • Use Cases are algorithms that interpret the input to generate the output data. • Use Cases diagrams highlight the Primary and secondary actors. 17 @ivanpaulovich
  10. Controller Use Case Core User Interface @ivanpaulovich Request Response Input

    Output • Abstract • General • Stable • Consistent • Concrete • Specific • Unstable • Inconsistent
  11. Entities Entities Clean Architecture Entities Use Cases Controllers Gatew ays

    Presenters D evices W eb UI DB External Interfaces @ivanpaulovich •Abstractness increases with stability. •Modules depend in the direction of stability. •Classes that change together are packaged together.
  12. Entities Use Cases Controllers Presenters Gateways Devices UI DB Web

    External Interfaces Abstract,
 General,
 Stable,
 Consistent Concrete,
 Specific, 
 Unstable, Inconsistent Level Clean Architecture @ivanpaulovich
  13. Deposit Use Case Customer Repository Account Repository Fakes User Interface

    Integration Tests s Account Repository Test Customer Repository
  14. Tests Overview In Process Out of Process Memory Within the

    application memory Reads I/O. Secondary memory. Speed Fast Slow Setup Effort Easy to design a variety of cases Requires extensive setup Samples Use Cases, Domain Repositories, Services
  15. Wrapping up Clean Architecture • Clean Architecture is about usage

    and the use cases are the central organizing structure. • Use cases implementation are guided by tests. • The User Interface and Persistence are designed to fulfil the core needs (not the opposite!). • Defer decisions by implementing the simplest component first. 53 @ivanpaulovich
  16. References https://cleancoders.com Clean Code: Component Design Clean Code: SOLID Principles

    Clean Code: Fundamentals https://github.com/ivanpaulovich/clean-architecture-manga Robert C Martin - Clean Architecture and Design @ivanpaulovich