software-architecture-for-developers
software-architecture-for-developers
for developers
Simon Brown
Simon Brown
Independent consultant specialising in software architecture,
plus the creator of the C4 model and Structurizr
What is software
architecture?
Structure
The de nition of software in terms
of its building blocks and their interactions
fi
Vision
The process of architecting;
making decisions based upon business goals,
requirements and constraints,
plus being able to communicate this to a team
Enterprise Architecture
Structure and strategy across people, process and technology
System Architecture
High-level structure of a software system
(software and infrastructure)
Application Architecture
The internal structure of an application
“ ”
As a noun, design is the named structure
or behaviour of a system … a design thus
represents one point in a potential
decision space.
Grady Booch
“ ”
All architecture is design, but
not all design is architecture.
Grady Booch
“ ”
Architecture represents the
signi cant decisions, where signi cance
is measured by cost of change.
Grady Booch
fi
fi
As architects, we de ne
the signi cant decisions
fi
fi
Architecture Programming language
Monolith, microservices or hybrid approach
Design
fi
Software lives in the real world,
and the real world has
constraints
Typical constraints include
time and budget, technology,
people and skills, politics, etc
Constraints can sometimes
be prioritised
Principles
are selected by the team
Development principles include
coding conventions, naming
guidelines, testing approaches,
review practices, etc
Architecture and design principles
typically relate to modularity
or crosscutting concerns
(architectural layering, separation of concerns,
stateless vs stateful, rich vs anaemic domain,
security, error handling, logging, etc)
Ensure you have a good
understanding of the requirements,
quality attributes, constraints
and principles to create
su cient foundations
ffi
What about agile,
and agility?
Agile is about moving fast,
embracing change, releasing often,
getting feedback, …
Agile is about a mindset of
continuous improvement
Inspect and adapt
“ ”
Continuous attention to
technical excellence and
good design enhances agility.
Principle 9 of the Manifesto for Agile Software Development
A good architecture
enables agility
A good architecture rarely
happens through
architecture-indi erent design
ff
Modular
Microservices
monolith
Modularity
Monolithic Distributed
big ball of mud big ball of mud
Software
Architecture
Document
AaaS
Architecture as a Service
The software architecture role
is about the “big picture”
and, sometimes, this means
stepping away from the code
The software architecture role
(technical leadership, and responsible for the technical success of the project/product)
ff
Soft skills
(leadership, communication, presentation, in uencing,
negotiation, collaboration, coaching and mentoring,
motivation, facilitation, political, etc)
fl
Domain knowledge
(or the ability to learn quickly)
The software architecture role
is multi-faceted
(technology, soft skills, domain knowledge)
Software architects,
solution architects,
tech leads,
principal engineers?
Technical priorities
vs
product priorities?
The product owner(s) and
software architect(s) are peers
(“Architecture Owner” is another term you can use)
“ ”
Everybody should
be an architect
“everybody is responsible for architecture”
!=
everybody being responsible for architecture
Everybody should
*
Service X
simonbrown.je
Did you nd anything
about this exercise
challenging?
fi
Take a quick look at the diagrams:
1. Does the solution satisfy the architectural drivers?
2. If you were the bank, would you buy this solution?
Swap your diagrams
with another group
Review the diagrams
Focus on the diagrams rather than the design
… notation, colour coding, symbols, etc
Producer Consumer
fl
7
7
7
7
7
7
6
If you’re going to use “boxes & lines”,
at least do so in a structured way,
using a self-describing notation
Moving fast in the same direction
as a team requires
good communication
Do you use UML?
In my experience,
fl
Is that how it really works?
(ensure that your diagrams re ect
your actual codebase)
fl
When drawing software
architecture diagrams,
think like a software developer
If software developers created building architecture diagrams…
Off-peak electricity
Peak electricity
Hallway
Water out
Water in
Stairs Bathroom Bed2 Bed3
fi
Software System
Web
Application
Logging
Component
Relational
Database
Ubiquitous
language
A common set of abstractions
is more important
than a common notation
Abstractions
Software System
Zoom in
Zoom in
Zoom in
Overview
2. Containers
The overall shape of the architecture and technology choices.
[Person]
Allows customers to view information
A customer of the bank, with about their bank accounts,
personal bank accounts. and make payments.
Mainframe Banking
API Application
[Container: Java and Spring MVC] System Facade
[Component: Spring Bean]
No Yes
fl
Single Page Application Makes an API request to API Application
[Container] [Container]
Sends an API response to
Trade data
simonbrown.je
Designing software is where
the complexity should be,
not communicating it!
Similar levels of abstraction provide
a way to easily compare solutions
The diagrams should spark
meaningful questions
No
“What does that arrow mean?”
“Why are some boxes red?”
“Is that a Java application?”
“Is that a monolithic application, or a collection of microservices?”
“How do the users get their reports?”
Yes
“What protocol are your two Java applications using
to communicate with each other?”
“Why do you have two separate C# applications instead of one?”
“Why are you using MongoDB?”
“Why are you using MySQL when our standard is Oracle?”
“Should we really build new applications with .NET Framework
rather than .NET Core?”
Richer diagrams lead to
richer design discussions
Richer diagrams lead to
better communication,
making it easier to scale teams
System landscape diagrams
Runtime/behavioural diagrams
Static structure diagrams
are very useful, but they
don’t tell the whole story
Use dynamic diagrams to describe
patterns or complex interactions
Deployment diagrams
Deployment is about the mapping
of containers to infrastructure
Deployment Node
Physical infrastructure (a physical server or device),
virtualised infrastructure (IaaS, PaaS, a virtual machine),
containerised infrastructure (a Docker container),
database server, Java EE web/application server,
Microsoft IIS, etc
A deployment node can contain
other deployment nodes or
software system/container instances
Infrastructure Node
Routers, rewalls, load balancers,
DNS providers, edge caches, etc
fi
FAQ
Part 1
“ ”
C4 has been around over a decade
- if it was truly useful, it would have
replaced UML in most teams
C4 wasn't designed
to replace UML
C4 was designed to bring structure to
the typical ad hoc "boxes and arrows"
diagrams teams typically create
because they are no longer using UML
I've seen more interest than ever in
C4 over the past few years; many
organisations have adopted it as their
preferred approach for software
architecture diagramming
I’ve run software architecture
workshops
in 30+ countries
for 10,000+ people
across most industry sectors
My C4 model book is also
used as course material
in many other universities
Tooling?
What tooling do you recommend
for long-lived diagrams?
c4model.com
FAQ
Part 2
Message-driven
architectures
Shared libraries
Microservices
“ ”
C4 is more suited to monolithic
architectures, and doesn’t support
distributed architectures well
“ ”
We’re modelling microservices as
containers, with APIs and database
schemas as components
A microservice should be modelled
as one of the following:
1. A software system
2. A container
3. A group of containers
What is a
“microservice”?
Stage 1: 💵
(monolithic architecture)
Stage 2: 💵 💵
(microservices)
software system
Stage 3: 💵 💵 💵
(Conway’s Law)
Dependencies to
“external” containers
My recommendation is that container
diagrams only show containers inside
the software system that is the scope
of the diagram
Container diagram for software system A
container a {
include *
}
Container diagram for software system B
container b {
include *
}
I don’t recommend showing
“external” containers
Container diagram for software systems A and B
container a {
include a.app b.api
}
Showing “external” containers implies
some understanding of
implementation details, which makes
the diagrams more volatile to change
This is a form of coupling
There may some useful exceptions
to this guidance…
Container diagram for software system A, showing a shared DB
container a {
include a.app c.db
}
Container diagram for software system B, showing a shared DB
container b {
include b.api c.db
}
“ C4 doesn't scale
”
In this example,
a microservice is
a combination of
an API and
a database schema
container softwareSystem {
include user
Include ->service1->
}
container softwareSystem {
include ->service2->
}
container softwareSystem {
include ->service3->
}
A nal note...
fi
Level 1 Level 2 Level 3 Level 4 Level 5
Software
Code Data
Architecture Data models, entity
A description of the software A description of important or
relationship diagrams,
This is a starting point; add and
architecture, including static complicated component
structure (e.g. containers and implementation details,
security, data volumes, remove sections as necessary.
archiving strategies, backup
components) and dynamic/ patterns, frameworks, etc.
strategies, etc.
runtime behaviour.
http://thinkrelevance.com/blog/2011/11/15/documenting-
architecture-decisions (Michael Nygard)
fi
Documentation format?
Microsoft Word, Microsoft SharePoint,
Atlassian Con uence, Markdown or AsciiDoc, etc
fl
How long?
Something I can read in 1-2 hours;
a good starting point for exploring the code
How do you keep software
architecture documentation
up to date?
C4 model diagrams
+
software guidebook/arc42
+
0% 100%
“ ”
it depends
Sometimes requirements are known,
and sometimes they aren’t
(enterprise software development vs product companies and startups)
“ ”
just enough
Up front design is not
necessarily about creating a
perfect end-state or
complete architecture
Iteration (via prototyping and experimentation) is great for product design but…
Martin Fowler
https://martinfowler.com/articles/designDead.html
A starting point
adds value
If you don’t engage in the problem, you end up with
a very simpli ed and super cial view of the solution
fi
fi
Part of the design activity is about
discovering “unknown unknowns”
Plateau
Accelerated learning
2. Is it going to work?
Diagrams are a visual checklist
for design decisions
System Context diagram
What is the scope of the software system we’re building?
Who is using it? What are they doing?
What system integrations does it need to support?
Container diagram
What are the major technology building blocks?
What are their responsibilities?
How do they communicate?
Understand the
structure
and create a
shared vision
1. Is that what we’re going to build?
2. Is it going to work?
Teams need to explicitly
manage technical risk
Problems with new technology
Low
1 2 3
Impact
Medium
2 4 6
2
High
3 6 9
3
The software architecture role
should own the technical risks
Architecturally signi cant?
costly to change | complicated | new
fi
Like estimates,
risks are subjective
Visual and collaborative “games”
Risk-storming
A visual and collaborative technique for identifying risk
Threat modelling
(STRIDE, LINDDUN, Attack Trees, etc)
“ ”
Base your architecture on
requirements, travel light
and prove your architecture
with concrete experiments.
Agile Architecture: Strategies for Scaling Agile Development
Scott Ambler
Concrete experiment
Proof of concept, prototype, spike, tracer, vertical slice,
walking skeleton, executable reference architecture, …
Just enough up front design to create
rm and su cient foundations
fi
ffi
How much up front design
should you do?
#52
You understand the context and scope You are con dent that your design
of what you’re building. satis es the key architectural drivers.
Techniques: Workshops, interviews, Event Storming, Impact Mapping, domain modelling, OOAD, CRC, DDD,
architecture reviews, ATAM, architecture dry runs, Risk-storming, concrete experiments, C4 model, ADRs, etc.
fi
fi
fi
fi
fi
How long?
Hours, days or weeks … not months or years
Some Design Up Front
+ Evolutionary Design
Some up front design to create a
starting point and direction
for further evolutionary design
Estimates?
“ ”
we used to do things like this,
it worked but we stopped doing
it when we became agile
Adopt an agile mindset
Choose a starting point and continuously improve
to discover what works for you
Thank you!
https://leanpub.com/b/software-architecture
Simon Brown