A talk I gave at the WaterfordTech meetup on 26/07/2017.
The talk focusses on the problem of writing good code, why do we find it so hard? Once we understand the problem, we can look at solutions, and then we focus on how a clean architecture can be applied to give us that first step of clarity that leads to good code.
The code used in the examples can also be found here (use arrow keys to navigate pages)
Cleaning up your codebase with a clean architecture
Cleaning up your Codebase
With a Clean Architecture
Expressing complexity through separation of concerns
Who am I?
Lead Developer and Solutions Architect for
Writing web apps professionally for 12 yrs
DDD and EventSourcing fanatic (I will talk for hours)
Recovered Architecture Astronaut
Organiser of PHPDublin @barryosull
Why is Writing Good Code so Hard?
What is a Clean Architecture?
How do you apply a Clean Architecture?
The Core of the Problem
"Our codebase is really messy and hard to
use. How do we clean it up?"
"Simple. We just need to refactor it, move code
into objects, separate the concerns."
How do we do that?"
"Easy. We'll use design patterns and follow the
SOLID principles. Job done."
Why doesn’t this work?
Only talks about these
Never talks about these
“How do you make things?”
NB: Layers can only reference concepts from their layer
and inners layers. They can never point at outer layers.
Business Requirements Change
“A user can upload a profile picture”
New User functionality
Update datamapper and add
Application Requirements Changes
No change to Users
Add a new Usecase
Add a new Controller
Add a new Twilio Service
“A user can change their email address via text ”
Implementation Requirements Change
“User Signup is slow, because checking email uniqueness takes ages, it should be faster”
No business logic changes
Usecases stay the same
Controllers stay the same
Redis used as a faster
datastore in implementation
Q: Why is Writing Good Code so Hard?
Because we don’t define the problem our architecture is solving
Q: What is a Clean Architecture?
A model for decoupling code through common categories to make
complexity and changes easier to manage
Q: How do you apply a Clean Architecture?
By removing outer layer language from inner layers, making each layer
simpler, consistent and concise
Question Time! More Material
● Implementing Domain Driven Design by
● Uncle Bob’s “Clean Architecture” Article
(1st google result)
(I tweet/write/talk about this stuff a lot)
● Or just talk to me afterwards!