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

Construcción de web-apps: Un enfoque hexagonal

Construcción de web-apps: Un enfoque hexagonal

Avatar for Gustavo Delgado

Gustavo Delgado

September 01, 2016

Other Decks in Programming

Transcript

  1. Arquitectura “Si en una sala llena de diseñadores de software

    dos de ellos están de acuerdo, eso es una mayoría” Bill Curtis
  2. MVC comes to rescue you Create Project POST /v1/customer/1/project …

    I think Web endpoint Controller/ProjectController
  3. MVC comes to rescue you Create Project POST /v1/customer/1/project …

    I think Web endpoint Controller/ProjectController Concrete Concrete Concrete Concrete Concrete
  4. MVC comes to rescue you Create Project POST /v1/customer/1/project …

    I think Web endpoint Controller/ProjectController Database context Web context Filesystem context
  5. Domain logic wired to different contexts Web, HTTP Database, ER

    manager Controller, Request Create Project
  6. Summary of pros/cons Pros - Rapid application development (R.A.D) -

    Low learning curve - Lots of frameworks in any flavour - Good documentation Cons - Rapid application development (R.A.D) → becomes B.A.D (Bad application development) - Too much coupling between layers - Not good abstraction - Technical debt - Domain logic wired to the framework
  7. Arquitectura Hexagonal “Hexagonal Architecture is an architecture defined by establishing

    a perimeter around the domain of your application and establishing adapters for input/output interactions. By establishing this isolation layer, the application becomes unaware of the nature of the things it's interacting with.” Alistair Cockburn
  8. • Decoupled application from dependencies • Ports (have a language)

    • Adapters (mutate message from port to application). All right, a better explanation Application Port Port Port Port
  9. Create Project - POST /customer/1/project Create project, a better approach

    Web endpoint Web endpoint CreateProject CreateProjectFolder CreateProjectEntity
  10. Alright, show me the code... Adapter mutate message from the

    web port ProjectController Good abstraction Context: Create a project
  11. Alright, show me the code... Adapter mutate message from the

    web port CreateProjectCommand ProjectController CreateProjectCommand
  12. Summary of pros/cons Pros - Low technical debt === good

    architecture - Decoupled layers - A good approach for complex applications with several developers - Good abstraction for the domain logic - Reuse your beautiful code Cons - It’ not too easy to implement as MVC - In some cases the Hexagonal documentation is too abstract