Application Architecture
Iván Stepaniuk
@istepaniuk
Architecture,
the lost years
Robert C. Martin
“Web” is not an
architecture.
Frameworks are
not architecture.
Symfony is a tool,
not architecture.
Application metaphor, the three layers
1 32
WAIT!
What does this even mean?
1. Interact with the user, both ways
1 32
3. Interact with outside world, other systems
1 32
2. The code that justifies the app existence
1 32
Are these layers equally important?
Do we build them the same way?
Do these change at the same pace?
It is all about
CHANGE
OK
How does business logic look like?
Patterns
Enterprise
Application
Architecture
Martin Fowler
Transaction Script
Modeled as procedures
+ Easiest to understand.
+ Obvious transaction boundaries.
- Difficult to de-duplicate.
Table Module
Modeled as objects and Record Sets
+ No DB vs. OO impedance mismatch.
- Model is database-centric.
- Objects, but not really OO.
Domain Model
Modeled after the business you work with.
+ Real OOP, with all the OO advantages.
- Hard to switch to if used to think data.
- Code overhead for simple logic.
Domain Model
Modeled after the business you work with.
+ Real OOP, with all the OO advantages.
- Hard to switch to if used to think data.
- Code overhead for simple logic.
Which pattern should I use?
Which one should we use?
Efforttoenhance
Complexity of the business logic
Which one should we use?
Efforttoenhance
Complexity of the business logic
7.42
Which pattern does symfony follow?
Domain Model
Architecture
Antipatterns
Anemic Domain Model
- Objects have state, but no behavior
- The Business is somewhere else
Leads to:
- Upside down Transaction Script
- God objects
Anemic Domain Model
- Objects have state, but no behavior
- The Business is somewhere else
Leads to:
- Upside down Transaction Script
- God objects
Inheritance!
To extend behaviour
Table Driven Domain Model
- The data model is the domain model
- All objects backed up by a table
Leads to:
- High viscosity
- Complex, slow, fragile tests
- CRUD obsession
Table Driven Domain Model
- The data model is the domain model
- All objects backed up by a table
Leads to:
- High viscosity
- Complex, slow, fragile tests
- CRUD obsession
CREATE
READ
UPDATE
DELETE
DATABASE
DATABASE
DATABASE
DATABASE
Connected Domain Model
In a connected system, elements are highly available to each other.
Adding the first feature to a connected system is cheap …
… the cost of all those connections is that subsequent features
are very likely to interact with previous features, driving up the the cost …
In a modular design, connections are deliberately kept to a minimum.
The cost of the first feature is likely to be higher …
Features are less likely to interact in a modular system, though,
leading to a steady stream of features at relatively constant cost.
- Kent Beck
Connected Domain Model
WAIT!
OK, Active Record is bad, but
what about productivity?
Symfony vs. OOP
Symfony vs. OOP
Is not the debate here
Hexagonal Architecture
or Ports and Adapters
Domain boundaries
Entities Services
Values
Integration
Domain boundaries
Entities Services
Values
Integration
Hexagon
Entities
Services
Values
Hexagon
Entities
Services
Values
Controller
Entity
Manager
Mail system
Template
Form
Queue
Upstream
Service
Or layers again
1 32
Delivery Domain Infrastructure
Or layers again
1 32 Srv
ValuesController
Entity
Manager
Template
Form Queue
Upstream
Service
Entities
Delivery Domain Infrastructure
Questions?
Or come and ask me later!

Application architecture