Mi Monolito Mola Mucho
Cristian Cotes
@ccotesg
#SCBCN18
Software Crafters Barcelona - VI Edition
Motivation
Monolith Microservices
Contexts
● Responsibilities: developer, lead, marketing, designer, CEO…
● Motivation/goals: learn, lead, reach users, style, money...
● Team: consolidated, new, growing…
● Type of product: MVP, prototype, stable…
● Type of company: startup, big enterprise, SMEs
Everything is a trade-off
VS
Rápido y mal
Lento y bien
Rápido y bien
What is a monolith?
Pros
● Cheap communication: objects/modules vs systems
● Allows you to explore complexity and boundaries
● Easy to deploy
● Easy to start with the development
● Single database*
Cons
● Single point of failure
● Single database*
● Hard to scale*
● Hard to maintain*
● Huge test battery
Coding horror
(Some nice examples)
Rule 1: Create use cases
Examples:
● SendMessageUseCase
● EditMessageUseCase
● ForwardMessageUseCase
● CreateUserUseCase
● ActivateUserUseCase
● ...
Rule 2: Encapsulate your business logic
● Create Objects with its own behaviour
● Instantiate/create them inside use cases
● Don’t expose their implementation
Rule 3: Hide implementation details
● Database implementation
● Message brokers
● 3rd parties services
● Frameworks
DomainApplicationInfrastructure
Repository
Implementation
HTTP server
Use Case
Repository
Interface
Object / Entity
Infrastructure
Application
Domain
Rule 4: Create slices
Infrastructure
Application
Domain
Rule 5: Extract commonalities
● Common folder
● Future independent libraries
Can I skip the rules?
Testing
● Testing by layers
● Unit test
● Integration
● End-2-end
Database
● Each slice has its on database/schema
● Queries across slices?
The purpose of a good architecture is to
defer decisions, delay decisions. The job
of an architect is not to make decisions,
the job of an architect is to build a
structure that allows decisions to be
delayed as long as possible. Why?
Because when you delay a decision,
you have more information when it
comes time to make it.
But...
Break? When?
● The team is big enough
● Some slices have special requirements (performance,
computation...)
● Slices with different non-functional requirements
Conclusion
● Understand your context
● Study the trade-offs
● Optimize your decisions
● Rules for the win!
● Monoliths are so cool, if you know how to build them! :)
Mi Monolito Mola Mucho
Cristian Cotes
@ccotesg
One more thing...
● DDD complexity
● Domain services, domain events, aggregates…
● Frontend

Mi monolito mola mucho