On Github devcrafting / emergentDesignTalk
Clément Bouillier - Devcrafting - @clem_bouillier
There is no silver bullets
That's not a judgement of what you do, just an option
Your "confort zone" will be heckled
We will discover some "hype" patterns like CQRS, DDD, EventSourcing...that's the how, but we will start with why
With software, you have much more agility than with concrete building
Early choices are predictions, but we are really bad at predictions!
Keep options to decide later
Your code will be simpler: KISS! (Keep It Simple Stupid)
You will perhaps not use them: YAGNI! (You Aren't Gonna Need It)
You can probably do the same with few lines of code
Basically what we call hexagonal (or also clean, onion...) architecture
Or also micro-services architecture (buzz word these days!)...
That's what we call "simplicity"
Emergent design & simplicity leverage each other
Ie. when you really need to take a decision
For demo, you can afford some temporary solutions for example...
Note: there are some controversial discussions on its meaning: Alistair Cockburn (fr)
You know twitter? Let's try to implement some sort of Twitter app...
For example, why would you systematically do CRUD in first place?
Probably, users do not need CRUD!
Focus on ESSENTIAL complexity: start with features/user stories
Describe them with a test, then develop the simplest solution without any implementation details. You will take care of that later.
Your goal: focus on which data to display, not from where/how to retrieve data
A simple solution: a view with a read model and its repository representing exactly what you want in this view
Your goal: enforce rules around tweeting a message (max nb chars...)
A simple solution: a Domain Model or Aggregate (Message for ex) that (1) handles some Commands (input), (2) enforces rules and (3) raises some Events to represent what happened in the system
NB: you just have done a bit of CQRS (Command/Query Responsability Segregation)
That's right! The simplest solution: an event handler that handles MessageTweeted events (Feature 2) to update the timeline read model (Feature 1)
Avoid to overload existing object (like User for ex) when no obvious relation with existing function (take care of "lack of cohesion")
A simple solution: create a new Aggregate that will take care of its own rules (Subscription for ex)
NB: you just have done a bit of DDD (Domain Driven Design) with two Bounded Contexts defined, one for Messaging, one for Subscription
Keep things isolated and simple, but refactor as you go to make emerge some simple concepts that will allow you to keep options for later
Avoid big ball of mud models (that seems to model reality), learn to separate things in Aggregates and Bounded Contexts
Avoid to systematically implement transactional consistency, learn more about eventual consistency
No matter which solution you choose, it will help you use emergent design
That's another subject, but somewhat related
...where requirements have been specified at a very detailed level, with lots of implementation details, which are probably not what users will need at the end.
With some katas, go to coding dojos...
Participate to communities events, conferences, read blogs...
Do not rely on your skills, explore other technologies/ways of doing things...
Read more on this subject...it is a mindset, not a certification or some other marketing thing!
Else you could end up with a big bull of mud, because of no refactoring, no code review, no pair programming, quick and dirty falacies...
THAT IS DEFINITELY NOT THE SAME AS EMERGENT DESIGN!
A step by step discovery of CQRS and EventSourcing concepts through code (sort of Koans)
Available in C#, Java, Javascript and PHP
Design starting with events, then find commands, then identify aggregates and discover contexts
Really great tool to discover your domain and force you to avoid upfront data model