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

Dive to clean architecture with golang

bmf_san
July 03, 2019

Dive to clean architecture with golang

bmf_san

July 03, 2019
Tweet

More Decks by bmf_san

Other Decks in Programming

Transcript

  1. Table of contents • What is the clean architecture? •

    Implementation of clean architecture • Conclusions
  2. Ideas for architecture of systems • Over the last several

    years… • Hexagonal Architecture (Ports and Adapters) • Onion Architecture • Screaming Architecture • DCI • BCE • etc…
  3. 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. Entities • Entities encapsulate the most important business rules •

    ex. an object with methods, a set of data structures and functions…
  5. Interface Adapters • Interface adapters is a set of adapters

    which convert data for entities and use cases
  6. 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
  7. 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
  8. Code reading • See the direction of dependency NBJOHP SPVUFSHP

    VTFS@DPOUSPMMFSHP VTFS@JOUFSBDUPSHP VTFS@SFQPTJUPSZHP VTFSHP ˣ ˣ ˣ ˣ ˣ *OGSBTUSVDUVSF *OUFSGBDFT 6TF$BTFT %PNBJO
  9. 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 ୡਓʹֶͿιϑτ΢ΣΞͷߏ଄ͱઃܭ
  10. 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
  11. 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
  12. 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