dancing about architecture
DESCRIPTION
Agile has democratized software architecture, taking it out of the hands of the few and putting it into the hands of the many. But architecture is a complex thing, and there are lots of mines in the meadow. This presentation provides some key things to keep in mind as you contribute to the evolution of your Rails application.TRANSCRIPT
![Page 2: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/2.jpg)
The idiomatic approach embodied in Railsenables rapid development.
![Page 3: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/3.jpg)
• Built in discrete layers• Models, views, and controllers• Controllers implement CRUD• Routes are RESTful• /lib = whatever doesn’t fit MVC
IdiomaticRails
![Page 4: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/4.jpg)
But rapid development comes at a cost.
![Page 5: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/5.jpg)
• Business logic leaking through the layers
• Raw SQL in models
• Complex object dependencies
• Conditional logic everywhere
• Controllers with non-CRUD methods
• Route exceptions become the norm
• Slow test suite execution
• /lib overflow
symptoms of a mature rails application
![Page 6: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/6.jpg)
“Most software eventually degrades to the point where someone will declare the design to be unsound.”-- Uncle Bob
![Page 7: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/7.jpg)
• Rigidity
• Fragility
• Immobility
• Feature friction
warning signs of adegraded design
![Page 8: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/8.jpg)
Bad design happens one line of code at a time.
![Page 9: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/9.jpg)
• Duplicated code
• Long methods
• God objects
• Feature envy
• Class intimacy
• Contrived complexity
• Übercallbacks
commoncode smells
![Page 10: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/10.jpg)
• Reek
• Flog
• RSpec
• Bug reports
• Feature requests
• Intuition
refactoringtoolkit
![Page 11: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/11.jpg)
• TDD until it doesn’t hurt anymore
• Build the interface you want to have
• Hexagonal architecture
• Verbs as nouns
refactoringpatterns
![Page 12: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/12.jpg)
• Let the test suite tell you where the pain points are
• Test only what you’re testing
• Stub everything else
• If you can’t stub it, it’s supposed to be a method
• Avoid factories
• Refactor until your methods are shorter than your tests
test-drivendevelopment
![Page 13: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/13.jpg)
• Build a new object
• Add the methods you wish you had
• Wrap the methods that you do have
• Refactor until it’s symmetrical
interface-drivendesign
![Page 14: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/14.jpg)
• Layered architectures are a convenient metaphor but break down quickly in a real app
• Build a Ruby application and integrate it with Rails, not the other way around
• Allow your application to be driven by users, programs, automated tests, batch scripts, ...
• Don't think in layers, think in ports
• Everything is an API
hexagonalarchitecture
![Page 15: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/15.jpg)
hexagonalarchitecture
WebBrowser
RakeTask
APIClient
TestingFramework
APIServer
Database
Mocks
iOSApplication
CommandLine
Domain ObjectsPersistence
HTTP
Com
man
d Lin
eM
essaging
DefaultLogger
ExternalMonitoring
Service
EmailService
![Page 16: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/16.jpg)
• Classes don’t have to represent business objects
• Classes can represent processes
• Classes can represent interactions
• Classes can represent workflows
• Do you need a run method, or a running class?
gerunds:the verb-as-noun
![Page 17: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/17.jpg)
Agile development has democratized architecture.
![Page 18: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/18.jpg)
.: we are all architects.
![Page 19: Dancing about architecture](https://reader035.vdocument.in/reader035/viewer/2022081401/55621603d8b42af2128b525e/html5/thumbnails/19.jpg)
Be the best architect you can be.