Transcript
Page 1: Dancing about architecture

dancing about architecture

presented bycorey ehmke

[email protected]@bantik

Page 2: Dancing about architecture

The idiomatic approach embodied in Railsenables rapid development.

Page 3: Dancing about architecture

• 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

But rapid development comes at a cost.

Page 5: Dancing about architecture

• 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

“Most software eventually degrades to the point where someone will declare the design to be unsound.”-- Uncle Bob

Page 7: Dancing about architecture

• Rigidity

• Fragility

• Immobility

• Feature friction

warning signs of adegraded design

Page 8: Dancing about architecture

Bad design happens one line of code at a time.

Page 9: Dancing about architecture

• Duplicated code

• Long methods

• God objects

• Feature envy

• Class intimacy

• Contrived complexity

• Übercallbacks

commoncode smells

Page 10: Dancing about architecture

• Reek

• Flog

• RSpec

• Bug reports

• Feature requests

• Intuition

refactoringtoolkit

Page 11: Dancing about architecture

• 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

• 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

• 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

• 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

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

• 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

Agile development has democratized architecture.

Page 18: Dancing about architecture

.: we are all architects.

Page 19: Dancing about architecture

Be the best architect you can be.


Top Related