6. @bednarz_andrzej#DevoxxPL
Clean architecture – principles by
UB
• The only way to go fast is
to go well
• Architecture is not about
tools or frameworks
instead it screams
intended usage
• It allows to defer/change
decisions about UI, DB,
DI, frameworks
• It’s decoupled - aka
Hexagonal Architecture,
Plugin Architecture
• It’s testable (TDD)
• See Uncle Bob’s
presentation online
12. @bednarz_andrzej#DevoxxPL
How do we call an interactor?
Source: Uncle Bob, http://blog.8thlight.com/uncle-bob/2011/11/22/Clean-Architecture.html
13. @bednarz_andrzej#DevoxxPL
How do we return results?
Source: Uncle Bob, http://blog.8thlight.com/uncle-bob/2011/11/22/Clean-Architecture.html
14. @bednarz_andrzej#DevoxxPL
How do we call infrastructure
services?
Source: Uncle Bob, http://blog.8thlight.com/uncle-bob/2011/11/22/Clean-Architecture.html
22. @bednarz_andrzej#DevoxxPL
• Lots of additional code:
classes and interfaces
• DTOs and conversions
• Cost ...
The Dark Side
Img src: Uncle Bob, http://blog.8thlight.com/uncle-bob/2011/11/22/Clean-Architecture.html
23. @bednarz_andrzej#DevoxxPL
Cost – example with Rails
controller
Source: David Heinemeier Hansson - DHH, https://gist.github.com/dhh/4849a20d2ba89b34b201
Based on: Jim Weirich's "Decoupling from Rails"
24. @bednarz_andrzej#DevoxxPL
Cost – example with Rails
controller
Source: David Heinemeier Hansson - DHH, https://gist.github.com/dhh/4849a20d2ba89b34b201
Based on: Jim Weirich's "Decoupling from Rails"
25. @bednarz_andrzej#DevoxxPL
• „Coding an app in Rails is
always fun...
for the first 3 months”
• „After some time, small, little
things show up. Thin
controllers are not really so
thin anymore. The tests are
no longer below 1 minute.”
Troubles with the Rails way
Source: Andrzej Krzywda, http://rails-refactoring.com/,
http://blog.jetbrains.com/ruby/2015/03/interview-with-andrzej-krzywda/
27. @bednarz_andrzej#DevoxxPL
Easy to understand
• Explicit by design
• Clearly defined
separation of concerns
• Full control of
frameworks and tools
Clean arch – good sides
FAST
development
High
Maintainability &
Flexibility
with tests
28. @bednarz_andrzej#DevoxxPL
• Our way
• model mapper, generic classes,
lombok
• Uncle Bob’s suggestion
• Another (isolated) boundary
for DTO
• Greg Young’s suggestion
• CQRS
But DTOs and conversions - still
pain
Img src: https://www.microsoftpressstore.com/articles/article.aspx?p=2248809
29. @bednarz_andrzej#DevoxxPL
Think, what is fast and clean for
you
Img src: https://thesunnyseason.files.wordpress.com/2015/01/closet-before-and-after-1024x781.jpg