Dive to clean architecture with golang

Dive to clean architecture with golang

0c9a69560f916778b569086d792680bb?s=128

bmf_san

July 03, 2019
Tweet

Transcript

  1. 4.

    Table of contents • What is the clean architecture? •

    Implementation of clean architecture • Conclusions
  2. 6.

    Ideas for architecture of systems • Over the last several

    years… • Hexagonal Architecture (Ports and Adapters) • Onion Architecture • Screaming Architecture • DCI • BCE • etc…
  3. 8.

    Things that are produced by those architecture of systems is

    … • Independent of Frameworks • Testable • Independent of UI • Independent of Database • Independent of any external agency • →For eliminating dependencies and getting testability.
  4. 11.

    Entities • Entities encapsulate the most important business rules •

    ex. an object with methods, a set of data structures and functions…
  5. 13.

    Interface Adapters • Interface adapters is a set of adapters

    which convert data for entities and use cases
  6. 14.
  7. 15.

    The rules of layers • Not only four layers, we

    can change numbers of layers • An inner layer can’t know about an outer layers • The dependency direction is from an outer layer to an inner layer
  8. 20.

    DIP • Dependency Inversion Principle • One of the SOLID

    principles • Modules should depend on abstractions(e.g. interfaces) • Abstractions should not depend on details(e.g. concrete implementations) • For increasing loosely coupled between high level modules and low level modules • Modules will be more flexible
  9. 22.
  10. 24.
  11. 25.
  12. 27.
  13. 29.

    Code reading • See the direction of dependency NBJOHP SPVUFSHP

    VTFS@DPOUSPMMFSHP VTFS@JOUFSBDUPSHP VTFS@SFQPTJUPSZHP VTFSHP ˣ ˣ ˣ ˣ ˣ *OGSBTUSVDUVSF *OUFSGBDFT 6TF$BTFT %PNBJO
  14. 31.

    Conclusions • Architect should have leadership for handling clean architecture

    • handson, study session for understanding architecture …etc • There are different ways to interpret it • To expand knowledge for it together as a team • There are various patterns for transactions • A framework is just a tool, not a way of life. • Written on the page p.197 Clean Architecture ୡਓʹֶͿιϑτ΢ΣΞͷߏ଄ͱઃܭ
  15. 32.

    References - Github • Github • manuelkiessling/go-cleanarchitecture • https://github.com/manuelkiessling/go-cleanarchitecture •

    rymccue/golang-standard-lib-rest-api • https://github.com/rymccue/golang-standard-lib-rest-api • hirotakan/go-cleanarchitecture-sample • https://github.com/hirotakan/go-cleanarchitecture-sample
  16. 33.

    References - Blog • Blog • The Clean Code Blog

    • https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html • Recruit Technologies - GoݴޠͱDependency Injection • https://recruit-tech.co.jp/blog/2017/12/11/go_dependency_injection/ • Clean ArchitectureͰAPI ServerΛߏஙͯ͠ΈΔ • https://qiita.com/hirotakan/items/698c1f5773a3cca6193e • ΫϦʔϯΞʔΩςΫνϟͷॻ੶ΛಡΜͩͷͰAPIαʔόΛ࣮૷ͯ͠Έͨ • https://qiita.com/yoshinori_hisakawa/items/f934178d4bd476c8da32 • Go × Clean Architectureͷαϯϓϧ࣮૷ • http://nakawatch.hatenablog.com/entry/2018/07/11/181453
  17. 34.

    References - Books and Papers • Books • Clean Architecture

    ୡਓʹֶͿιϑτ΢ΣΞͷߏ଄ͱઃ ܭ • Papers • The Dependency Inversion Principle • https://web.archive.org/web/20110714224327/http:// www.objectmentor.com/resources/articles/dip.pdf