Visualising software architecture with the C4 model - Simon Brown, Agile on the Beach 2019

Agile on the Beach
16 Aug 201935:33

Summary

TLDRIn this talk, Simon Brown emphasizes the importance of effective communication in software architecture through clear and understandable diagrams. He critiques the common use of whiteboards and generic diagramming tools, advocating for the C4 model, which offers a structured approach to diagramming software systems. Brown highlights the need for diagrams that reflect reality and are comprehensible to developers, using UML as a foundation for abstractions and notation. He provides practical tips for creating diagrams that are both aesthetically pleasing and informative, ensuring they stand alone in conveying architectural information.

Takeaways

  • 📈 Embrace software architecture diagramming to improve communication and understanding within your team.
  • 🚫 Avoid using general-purpose diagramming tools like Visio for software architecture as they lack domain-specific features.
  • 🎨 Use the C4 model (Context, Containers, Components, Code) to structure your architecture diagrams at different levels of abstraction.
  • 📐 Start with high-level system context diagrams to establish the environment and users of your software system.
  • 🔍 Zoom into container diagrams to detail applications, data stores, and their runtime relationships.
  • 📂 Dive deeper with component diagrams to illustrate the structure of individual applications and their components.
  • 📝 Include a key legend in your diagrams for clarity, especially when using shapes, colors, and line styles.
  • 📝 Use descriptive text within boxes to provide context and responsibilities of each element in the diagram.
  • 🔄 Focus on bidirectional relationships in diagrams, but avoid clutter by summarizing or using a single arrow where appropriate.
  • 🖼️ Use icons to add an extra layer of information, but ensure the diagram still makes sense without them.
  • 🛠️ Explore domain-specific tools and plugins for the C4 model to streamline the diagramming process.

Q & A

  • What is the main focus of Simon Brown's talk?

    -The main focus of Simon Brown's talk is on software architecture, specifically diagramming, describing, and explaining software architecture in a way that is effective and understandable to various audiences.

  • Why does Simon Brown mention that UML usage is often lower than expected?

    -Simon Brown mentions that UML usage is often lower than expected because there are many reasons and excuses people give for not wanting to use UML anymore, such as it being seen as old-fashioned, not fitting well with agile practices, and the existence of myths and misconceptions about its value.

  • What is the C4 model mentioned by Simon Brown?

    -The C4 model stands for Context, Containers, Components, and Code. It is a way of mapping the levels of abstraction in software architecture through four levels of diagrams, allowing for clear and concise communication of the system's structure.

  • What are the four levels of diagrams in the C4 model?

    -The four levels of diagrams in the C4 model are: Level 1 - System Context Diagram, Level 2 - Container Diagram, Level 3 - Component Diagram, and Level 4 - Code Diagram. Each level provides a different level of detail and targets different audiences.

  • Why does Simon Brown emphasize the importance of not using Level 4 diagrams in the C4 model?

    -Simon Brown emphasizes not using Level 4 diagrams because they are often not worth the effort and can usually be generated automatically from the codebase. They can also be too detailed and cluttered, which detracts from the main purpose of the C4 model, which is to communicate the architecture effectively.

  • What is Simon Brown's advice on creating effective software architecture diagrams?

    -Simon Brown's advice for creating effective software architecture diagrams includes focusing on abstractions first and notation second, using clear and concise titles and descriptions, being careful with acronyms, using consistent layout and color coding, and ensuring that diagrams can stand on their own without needing additional explanation.

  • What are some common mistakes people make when drawing software architecture diagrams, according to Simon Brown?

    -Some common mistakes include using general-purpose diagramming tools that don't understand software architecture, overusing icons without context, hiding the narrative within the diagram, and creating diagrams that are too detailed or cluttered, which can confuse the audience.

  • What tooling does Simon Brown recommend for drawing C4 model diagrams?

    -Simon Brown recommends using tools that are specifically designed for the C4 model, such as PlantUML with C4 model plugins, or his own set of tools that he has developed, which range from free to commercial offerings.

  • How does Simon Brown suggest using icons in software architecture diagrams?

    -Simon Brown suggests using icons to add an additional layer of information, but only if they complement the diagram that already makes sense. The key is to ensure that the diagram remains understandable even if the icons are removed or their meaning is not immediately clear.

  • What is the importance of having a consistent key or legend in software architecture diagrams?

    -A consistent key or legend is important because it helps to explain the shapes, colors, line styles, borders, and acronyms used in the diagrams. This ensures that everyone, including new team members or those who are not familiar with the diagrams, can understand the meaning and structure of the diagrams.

Outlines

00:00

🗣️ Introduction to Software Architecture Diagramming

The speaker, Simon Brown, introduces the topic of software architecture and the importance of diagramming. He discusses the common reluctance to use UML and the prevalence of poor architecture diagrams. He emphasizes the need for effective communication in software development and suggests that UML can be a valuable tool despite its critics.

05:00

📚 The C4 Model for Software Architecture

Simon Brown explains the C4 model, which stands for Context, Containers, Components, and Code. He outlines the four levels of diagrams in the C4 model and their purpose, emphasizing the importance of abstractions over notation. The model aims to help developers and architects communicate software architecture effectively to different audiences.

10:01

🔍 System Context Diagram

The speaker illustrates how to create a system context diagram, which shows the software system in relation to its environment, including users and other systems. He uses the example of an internet banking system to demonstrate the process of identifying users and external systems and how they interact with the system.

15:02

📱 Container Diagram

Simon Brown explains the container diagram, which focuses on the applications and data stores within the software system and their runtime interactions. He details the components of an internet banking system, such as the web application, mobile app, API application, and database, and how they connect and communicate.

20:06

📁 Components Diagram

The speaker delves into the components diagram, which provides a detailed view of the architecture within a specific container. Using the API application as an example, he describes the components and their responsibilities, such as sign-in controllers and account summary controllers, and their interactions with other systems.

25:08

📃 Notation and Diagramming Tips

Simon Brown offers advice on notation and diagramming, emphasizing the importance of titles, layout consistency, and the use of acronyms. He discusses the use of boxes and lines to convey structure and relationships, and the need for a legend to explain diagram elements. He also advises against overcomplicating diagrams and recommends using tools that support the C4 model.

30:09

🚫 Avoiding Common Pitfalls

The speaker warns against common pitfalls in diagramming, such as using general-purpose tools like Visio, which are not tailored to software architecture. He recommends using tools that support the C4 model and provides his own recommendations for such tools. He also stresses the importance of abstractions over detailed notation and the need for diagrams to stand alone without additional explanation.

35:10

🙌 Conclusion and Q&A

Simon Brown concludes his talk by summarizing the key points of the C4 model and diagramming tips. He encourages the audience to adopt the model and avoid using level 4 diagrams. He invites questions from the audience, wrapping up the session with a call to improve software architecture documentation.

Mindmap

Keywords

💡Software Architecture

Software architecture refers to the structure of a software system, the discipline of creating such structure, and the documentation of that structure. In the video, Simon Brown emphasizes the importance of effectively communicating and documenting software architecture through diagrams, which helps teams understand and build systems collaboratively.

💡UML (Unified Modeling Language)

UML is a standardized modeling language used to visualize, specify, construct, and document the artifacts of software systems. The speaker mentions that while UML is widely known, it's not universally used, and he discusses reasons for its underutilization and how to overcome these challenges.

💡Diagramming

Diagramming in the context of software architecture involves creating visual representations of system components and their relationships. The video script highlights the challenges of diagramming, such as the use of whiteboards and the resulting poor quality of diagrams, and suggests that proper training and tools can improve this process.

💡C4 Model

The C4 Model is a method for visualizing and documenting software architecture using four levels of abstraction: system context, containers, components, and code. Simon Brown introduces this model as a structured approach to creating diagrams that can be understood by different stakeholders, from developers to product owners.

💡Containers

In the C4 Model, containers represent the runtime elements of a software system, such as applications, databases, and file stores. The video explains that containers are crucial for understanding how different parts of a system interact and are deployed.

💡Components

Components are the building blocks within a container, representing modular parts of the software system with well-defined interfaces. The video emphasizes the importance of accurately depicting components in architecture diagrams to reflect the actual code structure and responsibilities.

💡Notation

Notation refers to the symbols, shapes, and lines used in diagrams to represent different elements and relationships. The speaker provides tips on using consistent and clear notation to make diagrams more understandable and effective for communication.

💡Agile and Lean

Agile and lean methodologies are approaches to software development that emphasize flexibility, collaboration, and rapid iteration. The video discusses how good communication, including the use of architecture diagrams, is essential for teams to work effectively in an agile or lean environment.

💡Tooling

Tooling in the context of software architecture refers to the software applications used to create and manage diagrams. The speaker recommends against general-purpose diagramming tools and suggests using tools specifically designed for the C4 Model to improve the quality of architecture diagrams.

💡Communication

Effective communication is a key theme in the video, where it is stressed that clear and consistent communication through diagrams is vital for team collaboration and understanding. The speaker advocates for diagrams that can stand alone and convey a clear narrative without needing additional explanation.

Highlights

The talk focuses on software architecture, diagramming, and explaining software systems.

Simon Brown, an independent consultant, discusses the use and misuse of UML in software architecture.

The speaker addresses the common reluctance to use UML and the prevalence of poor architecture diagrams.

The importance of effective communication in software development is emphasized to avoid slowing down teams.

The speaker introduces the C4 model, which stands for Context, Containers, Components, and Code.

The C4 model provides four levels of diagrams to map different levels of abstraction in software architecture.

The speaker advocates for a back-to-basics approach to software architecture diagramming.

The importance of abstractions over notation is highlighted, with a focus on understanding the system's structure and components.

The speaker suggests using UML as a standard notation to diagram software systems, similar to how maps use key legends.

The C4 model is presented as a way to create diagrams that can stand on their own, providing clear and understandable information.

The speaker recommends against using general-purpose diagramming tools like Visio for software architecture diagrams.

The speaker provides tips for creating effective diagrams, including using titles, layout consistency, and avoiding excessive text or icons.

The speaker emphasizes the need for diagrams to reflect reality and be understandable to developers and other stakeholders.

The speaker suggests using tools specifically designed for the C4 model to improve the quality of software architecture diagrams.

The speaker concludes by encouraging the audience to focus on telling valuable stories with their diagrams rather than getting caught up in the details of notation.

Transcripts

play00:00

right good morning thank you for joining

play00:03

me

play00:03

so this talk is about software

play00:05

architecture and specifically

play00:07

diagramming and describing and

play00:08

explaining software architecture for

play00:10

those of you who don't know me my name's

play00:12

Simon Brown I'm an independent

play00:13

consultant specializing software

play00:15

architecture show of hands who here uses

play00:19

UML that's more than I was expecting

play00:25

which still not everybody so when I

play00:27

asked this question in my travels around

play00:29

the world it's typically a little bit

play00:31

lower than this and maybe this is a sign

play00:33

of why companies get me in so typically

play00:35

it's about Tim set of people who use UML

play00:37

and there are lots of reasons for this

play00:39

and I think I've heard every single

play00:40

reason you can possibly imagine as to

play00:42

why people don't want to use UML anymore

play00:44

and there's a book about this you can go

play00:46

by it's called 97 ways to sidestep UML

play00:49

by no formality and I've literally heard

play00:53

all of these different excuses some of

play00:56

these are just crazy you know you'll be

play00:59

seen as old-fashioned if you use UML

play01:00

it's not expected in agile the value is

play01:04

in the conversation and you know since

play01:07

we've been doing the outdoor thing we

play01:09

perpetuated lots of these myths and lots

play01:12

of these excuses for not using UML and

play01:14

of course one of the recommendations for

play01:18

drawing architecture diagrams to explain

play01:19

your software to other people is to just

play01:22

use a whiteboard and although that kind

play01:26

of makes sense on the face of it we

play01:29

don't teach people how to do this so one

play01:31

of the things I do is I get to travel

play01:32

the world and I run software

play01:34

architecture diagramming Carter's

play01:36

exercises where we give people

play01:38

requirements and I say go draw some

play01:39

pictures and we get diagrams like this

play01:43

and that and this one which is my

play01:48

favorite I think

play01:50

that's like London Heathrow Airport this

play01:55

one here shows that our system does

play01:57

business logic the logical view

play02:07

Stormtroopers whatsit crossing out

play02:11

renaming these are real pictures and

play02:18

real works that sort of run over the

play02:19

years and to be fair some of these are

play02:20

the more extreme diagrams because I'm

play02:23

trying to make a point let me show you

play02:25

some diagrams from a workshop I did last

play02:27

month it's not as bad as some of the

play02:31

diagrams I've just shown part of the

play02:34

exercises we get we switch diagrams so

play02:38

every group gets different set of

play02:39

diagrams to look at and we rcent to give

play02:42

these diagrams a score out of 10 what

play02:44

school would you give this diagram out

play02:46

of 10

play02:47

8 7 6 this is called a 7 it's not great

play02:55

doesn't tell you anything all right this

play02:57

one what score do you give that for 8

play03:00

note 7 this one 7 that one 7 there

play03:11

doesn't tell you anything this one here

play03:14

7 I did not I'm not making this up all

play03:19

of these people scored other group 7 out

play03:21

of 10 this one here 7 this one here no 6

play03:28

and the funny thing about this diagram

play03:30

it is actually has more detail than the

play03:33

others and for some reason the teams

play03:35

thought now this is too much and we

play03:37

don't understand it so we're gonna grate

play03:38

it lower so this whole just use a white

play03:40

ball thing doesn't necessarily work very

play03:42

well

play03:42

now the exercises I run they tend to be

play03:45

quite short they're like 69 to 90

play03:47

minutes so maybe people had more time or

play03:49

they had a tool they were allowed to use

play03:51

computers they could draw better

play03:53

diagrams and unfortunately that's not

play03:55

the case so if you go to Google and you

play03:57

do a search for the software actitude

play03:58

diagram it goes sure here are some

play04:00

diagrams for you and these are all

play04:02

garbage

play04:03

well so they look nice they're all Nina

play04:06

nice squarish boxes and stuff and we've

play04:09

got nice colors they all have exactly

play04:11

the same problems as the hand-drawn

play04:13

pictures we have boxes and no lines we

play04:15

have different shapes but we don't know

play04:17

why different colors we don't know why

play04:19

different sizes of boxes we have layers

play04:22

both horizontally vertically we have

play04:24

acronyms no titles there's just our

play04:26

whole bunch of stuff going wrong with

play04:27

all of these diagrams the building

play04:31

industry if we look at the building

play04:32

industry if you ask an architect to draw

play04:35

you a floor plan of where you live

play04:37

you'll get a floor plan and you can look

play04:40

at the floor plan and go yes I'm windows

play04:42

doors I get this if we were asked to

play04:44

draw a floor plan we go yeah sure here

play04:47

you go he's a floor plan of my house

play04:49

it's like what but logically and

play04:55

conceptually speaking this makes perfect

play04:57

sense so these little red dots here

play05:00

that's my Wi-Fi hot spot because it's

play05:05

important but don't ask me all the dash

play05:07

lines mean I have no idea so I think we

play05:10

need to take a little bit of a kind of

play05:13

back-to-basics approach because we

play05:14

should be engineers and we're trying to

play05:17

be artists and I think we should do

play05:19

something a bit more engineering and the

play05:21

whole point of this of course is if we

play05:23

want to be lean and agile we want to

play05:24

move fast as a team unit we need to

play05:27

communicate well and I've visited lots

play05:30

of organizations recently where their

play05:32

lack of communication is literally

play05:34

slowing them down because teams don't

play05:36

have a common vision of even what they

play05:38

are going to build or what they are

play05:40

building or what they have built one of

play05:43

the other things against UML potentially

play05:45

is that it's very technical in nature

play05:47

and if you want to describe your

play05:49

software systems to developers and

play05:50

architects that's fine if you want to

play05:52

talk to product owners scrum masters

play05:54

testers whatever there's a whole

play05:56

audience out there that doesn't

play05:57

necessarily know UML so we need to

play06:00

target again the storytelling we need to

play06:02

target our stories of different types of

play06:03

audiences so our top tip in all of this

play06:06

is when you're drawing architecture

play06:07

diagrams don't think like an architect

play06:09

think like a developer and this won't

play06:12

affect counterintuitive but when I'm

play06:14

running these design exercises

play06:17

the developers and the people who attend

play06:20

my workshops they can do the design part

play06:22

so they can design a solution but when

play06:25

you ask them to draw it they forget

play06:28

everything they've ever known they put

play06:29

their architects hat on and they start

play06:31

drawing all these really high-level

play06:32

fluffy conceptual pictures that

play06:34

literally make no sense and one of my

play06:38

goals here is when I when I get when I'm

play06:40

asking if you have to draw acted two

play06:41

diagrams good architecture diagrams I

play06:43

want them to reflect reality so when you

play06:47

show them into another developer they go

play06:48

yes and that's exactly what we're

play06:50

building I think in order to do this we

play06:54

could look at UML UML gives you a sense

play06:56

set of things and a standard notation to

play06:58

diagram those things I think the things

play07:00

the abstractions is actually much more

play07:02

important than the notation and one of

play07:05

the reasons people cite for not using

play07:07

UML is that the notation is very

play07:09

complicated so I'm a abstractions first

play07:14

kind of person here notation second and

play07:18

although this might sound a bit foolish

play07:19

if we go get two local maps of this area

play07:22

the two local maps are going to show you

play07:25

the same things aren't they the towns

play07:27

the train lines the bus routes the

play07:29

schools the churches the museums the

play07:31

points of interest the two maps will

play07:33

show the same things the same

play07:34

abstractions but they'll likely use

play07:36

different color coding line styles

play07:39

notations shading icon symbols and so on

play07:42

and the key to understanding a map is

play07:45

the key there's a key legend on the map

play07:48

and it tells you we know when you see

play07:50

this sign that's what it means and I

play07:52

think that's a really really powerful

play07:53

and simple concept that we can just

play07:55

borrow so what are the abstractions when

play07:59

I'm thinking about describing and

play08:01

documenting and explaining a software

play08:03

system for me that software system is

play08:06

made up of one or more containers not

play08:10

docker so I've been teaching this

play08:14

approach for well over 10 years now and

play08:16

docker got popular and kind of stole the

play08:19

word container by container I basically

play08:22

mean an application or a datastore so

play08:25

something to runs your code something

play08:26

you need to deploy and run somewhere or

play08:28

something where your data is being

play08:30

stored

play08:30

so in real terms a container might be a

play08:33

mobile app running on your mobile device

play08:35

back-end server side app a console app a

play08:39

Windows service written c-sharp a Python

play08:42

script a database schema a folder on a

play08:45

file share and Amazon s3 buckets a

play08:47

dynamo DB you know all of that type of

play08:49

stuff that's what I mean by container we

play08:52

look inside these containers I'm going

play08:54

to say they are made up of components so

play08:56

components is a hugely overloaded word

play08:59

but basically what I mean by component

play09:01

is a grouping with stuff yeah modularity

play09:04

nice boundary nice clean simple

play09:06

interface running inside a containers

play09:10

that's the important part here we've got

play09:11

a hierarchy and if we look inside

play09:13

components they're mostly made up of

play09:15

code level elements so if you're

play09:17

building your Java apps you have a bunch

play09:19

of components built with Java classes

play09:21

and interfaces for example and that's it

play09:25

it's a simple hierarchy a hierarchy of

play09:28

structural elements so we can then use

play09:30

to describe software architecture and

play09:31

then that leads me to the c-4 model

play09:36

which is in the title of this talk so if

play09:39

you want to point other people at the c4

play09:41

model you can go to c4 model dot-com c4

play09:44

stands for context containers components

play09:48

and code and it's four levels of diagram

play09:52

that map ons those levels of abstraction

play09:55

as Tendai said in the keynote I'm going

play10:01

to tell you a story and that story is

play10:03

going to be linear the one thing I do

play10:05

not want you to take away is Simon says

play10:07

we must draw diagrams in this order

play10:09

because a lot of people do that and then

play10:11

they kind of superimpose Simon therefore

play10:13

says we should do design in this order

play10:15

as well and that's not what I'm saying

play10:16

so this is just the collective diagrams

play10:18

you can draw in any order to describe

play10:20

your software systems at different

play10:22

levels of detail that's basically what

play10:23

this is all about and it's essentially

play10:26

the way I think about this is diagrams

play10:28

as maps so I live in Jersey in the

play10:31

Channel Islands and if you open up your

play10:33

your Maps app on your smartphone and you

play10:36

do search for Jersey you'll get that

play10:39

picture by default so Google Maps for

play10:41

example zoom straight in says are you

play10:43

interested Jersey

play10:43

this is what Jersey looks like if you

play10:46

want to know what the major places are

play10:48

in Jersey where I live that's useful if

play10:50

you've never heard of it and you've done

play10:52

the where Jersey is it's pointless you

play10:53

have no context so you get to zoom out

play10:55

or zoom in to tell different stories to

play10:58

get different levels of information and

play10:59

it's the same thing with these diagrams

play11:01

we have different levels of diagrams to

play11:03

tell different stories different

play11:04

audiences and the purpose of this talk

play11:07

is really just to show you the sea for

play11:09

kind of core diagrams the static

play11:10

structural diagrams but once you have a

play11:13

good idea of your static structure and

play11:15

you're able to talk about your static

play11:16

structure you can then use these same

play11:19

concepts to draw runtime diagrams

play11:22

sequence diagrams deployment diagrams

play11:25

and so on and so forth so this is kind

play11:27

of really nice starting place I'm going

play11:31

to show you a bunch of example diagrams

play11:32

based upon an internet banking system so

play11:35

imagine we work for a bank

play11:37

and the bank wants us to build an

play11:38

internet banking system so I'm going to

play11:41

start from the top again storytelling

play11:43

and I'm going to draw a level 1 system

play11:45

context diagram and the system context

play11:48

diagram basically shows the thing you

play11:50

are working on or building and stuff

play11:53

around it in terms of other systems it

play11:55

talks to and the people who use your

play11:57

system so we're going to start with a

play12:01

box in the middle and this represents

play12:03

our internet banking system as a

play12:05

software system don't worry about

play12:07

notation and shapes and color coding

play12:09

I'll cover all of those tips later so in

play12:12

order to draw this diagram we now need

play12:14

to ask a bunch of questions like who's

play12:16

using it so now we look at roles or

play12:19

users or personas and we come up with a

play12:22

bunch of people who are gonna be using

play12:23

our software system so in this example

play12:25

let's say there's only one type of user

play12:27

it's personal users of the personal

play12:29

banking customers so you and I as

play12:31

account holders we want to use the

play12:33

internet banking system to get

play12:35

information about our accounts and maybe

play12:36

make some payments where does this

play12:39

system get its information from well

play12:41

let's say the bank has an existing

play12:43

software system a mainframe back-end

play12:45

banking system and that's where all of

play12:47

the core banking data is stored so we're

play12:49

going to have some interaction with that

play12:51

let's also imagine for the purposes of

play12:53

this story that we need to send emails

play12:55

to our customers and rather than

play12:57

creating our

play12:58

an email system we just can use the

play12:59

bank's internal email system so that's a

play13:02

really nice simple example of a system

play13:03

context diagram it basically shows you

play13:05

that's the thing we are working on and

play13:08

this is the environment the context

play13:10

around it in terms of people and other

play13:12

software systems for large environments

play13:16

you have more boxes and there's a longer

play13:18

question there about how do you deal

play13:19

with larger diagrams and we can we can

play13:20

cover that in a Q&A if you want to so

play13:23

that's that's level one it's nice and

play13:25

high level nice and straightforward not

play13:27

much tech choices on here it's great for

play13:29

a really wide range of audiences

play13:32

so it's developers and architects we now

play13:35

want more detail so what's inside the

play13:37

interbank you system you know what tech

play13:38

is it made of how does it work so now

play13:40

what we're going to do is we're going to

play13:41

pinch to zoom in to that internet

play13:44

banking system box and we're going to

play13:46

drop down to level 2 and level 2 is a

play13:49

container diagram and this is showing

play13:51

you all of your apps and safe and data

play13:53

stores and how they relate and run at

play13:56

runtime and we're going to build this up

play13:59

piece by piece so the currently empty

play14:02

looking box here that is the internet

play14:06

banking system box from the previous

play14:07

diagram that's the thing we're going to

play14:09

look into and we're still going to show

play14:11

the people and the external systems we

play14:13

have some one dependency on caveat time

play14:17

what you're about to see is how I might

play14:20

design an internet banking system you

play14:23

might not agree with my design that's

play14:25

fine park those thoughts but this is how

play14:28

I might design the diagram and of course

play14:30

I needed to do that in order to show you

play14:31

a diagram so first we're gonna have a

play14:35

deployable web application so imagine

play14:36

you open up your web browser you go to

play14:38

my bank comm forward slash internet

play14:40

banking you get a bunch of static

play14:42

content back in your browser HTML CSS

play14:45

JavaScript that's gonna be served from

play14:49

this back-end web app which I'm going to

play14:50

say is a Java spring MVC app once you

play14:53

get all of the static content back into

play14:55

your browser I'm going to say that

play14:57

actually that's going to be a single

play14:58

page app essentially running client-side

play15:00

in your browser so I'm going to model

play15:02

that as a separate box in this diagram

play15:03

so now I've got a bunch of JavaScript

play15:06

code essentially running on my web

play15:07

browser that's my UI for my interbank

play15:09

Inc system it's a single

play15:11

jab in this case it's JavaScript and

play15:13

angular how about we give people a

play15:17

mobile app as well so let's build a

play15:19

separate mobile application using this

play15:22

case the cross-platform xamarin

play15:23

framework and that's an alternative UI

play15:25

that we can present present to our

play15:26

customers how do the single page app and

play15:31

the mobile app gets data from the

play15:32

backend banking system well they need to

play15:34

go through something so I'm gonna say

play15:36

we're gonna have a separate API

play15:37

application exposing a bunch of jason

play15:39

that over HTTP endpoints that's a

play15:42

separately deployable Java spring MVC

play15:45

web application so now we have two web

play15:48

applications where we're deploying

play15:49

server-side you could have one I'm

play15:51

choosing two we need to sign in so we go

play15:57

to the front page we need to add

play15:59

username password imagine we work for

play16:02

the bank we go ask the bank can we put

play16:04

our usernames and passwords in your

play16:05

back-end banking system they say no so

play16:09

we need to somewhere to store our own

play16:10

data so let's have our own database

play16:12

schema to do that so that's basically in

play16:15

this case an example contain a diagram

play16:17

it's showing you the various

play16:18

applications and data stores the

play16:20

technologies that built with a bit about

play16:22

responsibilities on there and how they

play16:24

connect at runtime so each of these

play16:27

containers is mostly no I'll tell you

play16:31

later why I'm using the word mostly

play16:33

mostly a separately deployable thing and

play16:36

the links the lines between the

play16:38

containers are mostly inter-process

play16:41

communication calls so something with a

play16:43

network involved somewhere typically

play16:47

that's level 2 let's imagine that we are

play16:50

now in a team and we are working on the

play16:54

API application and we want to see how

play16:56

that code base is structured so now

play16:58

we're going to pinch to zoom in and

play16:59

we're going to down so we're going to

play17:01

drop down to level 3 and I'm now going

play17:03

to draw you a components diagram for

play17:06

that API application now I'm going to do

play17:09

the same thing so this currently empty

play17:11

box here represents the API application

play17:13

box from the previous diagram it's used

play17:16

by the single page app and the mobile

play17:18

app and we're going to add some other

play17:19

stuff to this picture so

play17:22

you open up the mobile app you need to

play17:25

sign in so I'm going to say we need some

play17:27

sort of sign-in API so we can have a

play17:29

sign-in controller that's going to use

play17:32

some sort of security component we're

play17:33

just going to do authentication against

play17:35

our credentials in the database

play17:36

hopefully using hash passwords and all

play17:38

the rest of it once you signed in you

play17:41

get a list of your accounts let's

play17:42

imagine that that's serviced by a

play17:44

separate accounts summary controller

play17:46

again that's providing another API

play17:48

endpoint and that's going to use this

play17:50

really horribly names mainframe banking

play17:52

system facade component which talks to

play17:55

the horrible back in banking system if

play17:59

somebody wants to reset the password

play18:00

yeah we'll give them the way to do that

play18:02

as well in a more real-world example you

play18:08

could seed have many many more

play18:09

components on this diagram and again

play18:12

there's another question here about how

play18:13

do you deal with larger systems but this

play18:15

is a nice simple example of the

play18:17

components that sit inside that API

play18:19

application it's at this point of course

play18:22

that we now need to start talking about

play18:23

lower-level text choices so we got

play18:26

spring beans and spring MVC rest

play18:28

controllers and there's some other

play18:29

high-level Czech tech choices and

play18:30

frameworks on here if I were to open the

play18:33

code base for this API application I

play18:35

would expect to see very clearly these

play18:38

six things somewhere in my codebase so

play18:41

at level 3 at the component level your

play18:44

architecture diagram now needs to start

play18:47

reflecting your code structure at a high

play18:49

level so it needs to be a nice one to

play18:51

one mapping between concepts on this

play18:53

diagram and concepts in your code base

play18:55

whether those concepts are language

play18:58

level modules maven modules Gradle

play19:02

modules components packages namespaces

play19:07

jar files dll's so there has to be some

play19:09

organization structure which is reflect

play19:12

on your diagram South's level 3 level 4

play19:16

so I don't recommend doing level 4 I'm

play19:21

going to say that again because people

play19:24

always miss this I do not recommend

play19:27

doing level 4 because it's not worth it

play19:30

and often you could just generate level

play19:32

4 automatically from your IDs

play19:35

to show to tell the story I'm going to

play19:38

show you an example so let's imagine we

play19:39

are working on this horribly names of

play19:41

mainframe banking system facade

play19:42

component thing and we want to see

play19:44

inside it class diagram so this is where

play19:48

UML is super useful for documenting and

play19:50

diagramming those low-level aspects if

play19:53

you want to diagram level 4 for

play19:58

complicated components or when there's

play20:00

something bit funky going on feel free

play20:01

but in most in 99% of situations do not

play20:05

draw a level 4 diagrams just automate

play20:07

them for your your IDs so that's the

play20:10

diagrams system context containers

play20:13

components code and we're done

play20:17

notations important and there's lots of

play20:21

subtleties in the notation and the

play20:23

example diagrams I wanted to go through

play20:24

very very quickly so some tips for

play20:27

notation tip number one put titles on

play20:31

pictures I know this sounds super

play20:33

obvious but when I run my workshops 80%

play20:38

of diagrams first time rounds do not

play20:40

have a title and you have no idea what

play20:43

you're looking at so when I'm titling a

play20:45

diagram I want to be very explicit about

play20:47

two things what type of diagram is this

play20:49

and what's the scope so if I'm drawing a

play20:52

system context diagram for a financial

play20:55

risks and I'll let you leave it like

play20:57

that so I'm very specific and very clear

play20:59

here layout if you don't have access to

play21:02

whiteboards you know if you're writing

play21:04

on paper it's kind of hard to raise you

play21:06

can use sticky notes and then index

play21:08

cards represent your boxes

play21:09

move them around get a like you like

play21:11

that's fine

play21:12

I wouldn't necessarily deliver diagrams

play21:15

as a collection of sticky notes because

play21:16

they will fall off and it just kind of

play21:18

looks a bit cluttered I will try to aim

play21:21

for some visual consistency so if I've

play21:25

got multiple levels of detail I will try

play21:27

to always keep my people in the same

play21:29

visual location on the diagram cameras

play21:31

for example and I'll try to use the same

play21:33

color codings and shapes across all of

play21:35

my levels of diagram and you would have

play21:38

seen that in the examples I just showed

play21:39

you be super careful with acronyms if

play21:45

you are targeting your diagrams at

play21:48

technical people like developers and

play21:50

architects don't worry about explaining

play21:53

MVC and ASP and JDBC and all that stuff

play21:55

because we probably get that focus more

play21:59

on the domain-specific acronyms the

play22:02

business acronyms or the funny jargon

play22:04

that lives in your companies so code

play22:07

names for systems or code names for

play22:09

teams that sort of stuff catches our new

play22:11

joiners really really quickly boxes and

play22:16

lines so that start with boxes or more

play22:20

specifically elements when I'm drawing a

play22:22

diagram for the first time I'm going to

play22:24

forget about shape and color and I'll

play22:30

talk about why in a second but I'm going

play22:31

to just draw plain boring boxes and

play22:34

inside my boring boxes is a bunch of

play22:37

text if you look at the top three levels

play22:41

of the C for diagrams so context

play22:43

contains components these are basically

play22:45

the only four types of elements I expect

play22:48

to see on the diagrams so it's a very

play22:50

simple language you can teach people so

play22:52

the system contexts diagram shows people

play22:56

and software systems the container

play22:58

diagram shows people software systems

play23:01

and containers and the component diagram

play23:03

tension shows all of these things so

play23:07

every box is going to have a name a

play23:09

naming is hard and whatever but

play23:11

hopefully we're going to give everything

play23:12

a nice simple easy to remember name I'm

play23:15

also going to be very explicit about the

play23:18

type of the elements so I'm going to

play23:21

write in the box this is a person or

play23:23

this is a software system because then

play23:25

we know what we're getting and there's

play23:27

no guessing for the two technical things

play23:30

down here the containers and the

play23:31

components this is where we can start to

play23:32

weave in those text choices so this is a

play23:34

database scheme or this is a spring MVC

play23:36

app the rest of the text in the box is a

play23:40

short description either as a sentence

play23:43

like you see here or maybe just so you

play23:45

know five or seven bullet points to list

play23:46

out the key responsibilities of that

play23:48

element and it's at this point people

play23:51

say well why are you putting so much

play23:52

text in your boxes because that's not

play23:54

how we do actor two diagrams well that's

play23:57

why they're a problem

play23:58

so here are two example Arteta diagrams

play24:01

this is the one

play24:02

on the left is what we typically do it's

play24:03

just a bunch of named boxes and I do

play24:05

something like that on the right if I if

play24:10

you saw this diagram on the left for the

play24:12

very first time and I said to you can

play24:14

you describe what the content of data

play24:15

does your response would be it updates

play24:18

content yes what about the file system

play24:23

what is a file system do it stores files

play24:26

so the names are not particularly

play24:28

helpful but over on the right-hand side

play24:31

here we've got more text so even if the

play24:33

names are a bit odd and a bit ambiguous

play24:35

and bit vague at least we can now read

play24:37

the text and go okay the name doesn't

play24:39

make sense but now I know what the thing

play24:41

does so we're adding a degree of

play24:43

explicitness to our diagrams but do keep

play24:47

that short I've seen people writing

play24:49

entire essays in the boxes and that's

play24:51

not what our employer either lines pay

play24:54

some attention to lines because lines

play24:56

give you structure lines glue your boxes

play24:58

your elements together my preference

play25:01

here is you need directional lines only

play25:04

so all of my arrows go one way so you'll

play25:07

never see my diagrams with straight

play25:10

lines for now arrowheads or lines with

play25:12

arrowheads on both sides and this raises

play25:15

an interesting question we're twenty

play25:17

point arrows and it's up to you so there

play25:20

are no hard and fast rules in any of

play25:21

this my preference is for thing a calls

play25:25

thing B or thing a depends on thing B if

play25:27

you want to show events or messages or

play25:30

information flow that's absolutely fine

play25:32

just make sure the direction of your

play25:33

arrow matches the text you put on the

play25:35

arrow to describe it the other kind of

play25:40

catch here is that most relationships

play25:42

are actually bi-directional aren't they

play25:43

so if we think back to the intent

play25:45

banking system we've got the single page

play25:47

app and that's making a request to the

play25:50

API app and the API app is sending a

play25:53

response back essentially so two

play25:55

bi-directional relationship and although

play25:56

that makes sense if we show both

play25:59

directions for every relationship we

play26:02

came to get a very very cluttered

play26:03

diagram really really quickly so what

play26:05

I'm going to do instead is I'm going to

play26:07

summarize the intent of those two arrows

play26:09

in a single arrow so I would rather say

play26:12

something like that the single page

play26:14

application

play26:15

makes API calls using the API

play26:18

application I will try to avoid users

play26:23

again uses is quite a general vague

play26:26

generic term so I'll try to be as

play26:28

specific as I can but keep it short and

play26:32

having said all of this sometimes you do

play26:36

want to show both directions so if

play26:38

you're if you know you've got a

play26:40

bi-directional relationship but those

play26:41

two directions are very different in

play26:44

nature very different in its intent then

play26:45

I will show those directions so maybe we

play26:48

have two micro-services a and B and

play26:50

maybe at startup time a can request a

play26:54

list of stuff and be using a synchronous

play26:56

call so that's one relationship and then

play27:00

maybe at runtime as events are coming in

play27:02

we've got a kind of rule cast thing

play27:04

going on as well so because those are

play27:06

two very different types and

play27:07

relationships I want to show those very

play27:09

clearly on the diagram

play27:11

another trap people fall into is they

play27:14

kind of hide the two-story so imagine

play27:16

you drawing a container diagram you've

play27:18

got a microservices architecture

play27:19

everything was going into and out of a

play27:22

message bus you tend to get

play27:24

hub-and-spoke diagrams that look a lot

play27:26

like this and again although that's

play27:29

factually correct you know we've got a

play27:30

couple of micro versus here if stuffing

play27:32

things into a barson stuff coming out we

play27:37

may be missing some really important

play27:39

information so what I'd rather do is

play27:40

perhaps draw something like this instead

play27:43

so miss off the message bus and instead

play27:46

say actually there's a point-to-point

play27:47

relationship here between a and B and

play27:49

we're just using Kafka or rabbit as the

play27:51

messaging mechanism for doing that so

play27:55

again there are no hard and fast rules

play27:57

here it's really do the diagrams tell

play27:59

the story that you want to tell and add

play28:02

more words a lot of this is adding more

play28:04

words to make stuff much more explicit

play28:06

and a really good simple tip here is

play28:08

just read your diagrams out aloud so in

play28:12

this case the trade data system sends

play28:15

trade trade data to the financial risk

play28:17

system and because that makes sense as a

play28:20

sentence we could have a key legend so

play28:24

every set of diagrams should have a

play28:27

consistent key and

play28:29

to describe shapes colors line styles

play28:33

borders acronyms and so on even if it

play28:36

seems obvious to you so we're not a hawk

play28:39

tetra Carters we kind of draw some

play28:41

diagrams in the morning and everybody's

play28:43

using different color Sharpie markers

play28:44

then we go for lunch and then they come

play28:45

back and like why is this line red they

play28:48

drew two hours ago but they've forgotten

play28:50

this is an example of a diagram keyer

play28:53

diagram legend so this is my container

play28:56

diagram up here for the interbank II

play28:58

system and that's the key of the legends

play29:00

that I would use to describe this

play29:01

diagram so that - box is the system we

play29:06

got these various blue boxes here for

play29:08

showing containers and I'm using

play29:09

different shapes to show different types

play29:11

of containers

play29:12

people-people gray boxes are external

play29:15

software systems in this case I'm just

play29:18

saying there are relationships and I'm

play29:20

not being specific about relationships

play29:22

but you can be so if you want to show

play29:25

synchronous relationships different from

play29:27

asynchronous relationships you could do

play29:29

something like solid lines for

play29:32

synchronous relationships and and dash

play29:34

lines for asynchronous and you'd have

play29:36

that in your key or a lot or your legend

play29:37

if you wanted to use different colors

play29:39

for different protocols so maybe green

play29:42

lines are secured by HTTPS and red lines

play29:45

are insecure then feel free do watch out

play29:49

for colorblindness especially red-green

play29:51

color blindness and also watch out for

play29:53

black and white printers because that

play29:55

will happen at some point so with that

play29:58

in mind my advice is to use shape and

play30:01

color to complement a diagram that

play30:04

already makes sense so in other words if

play30:06

you take a diagram and you remove all of

play30:09

its color and you remove all of the

play30:10

shapes the diagram should still make

play30:13

sense and the reason it makes sense is

play30:16

because a lot of the texts we add to the

play30:18

diagram helps it make sense to versions

play30:23

of the same diagram which one D tend to

play30:27

prefer that one on the right yeah it

play30:32

kind of looks nicer it's a bit more

play30:33

aesthetically pleasing because you can't

play30:36

read the text so I can't read the text

play30:37

from here either by the way because you

play30:39

can't read the text

play30:42

looking at the diagram on the right

play30:43

you're you're able to kind of understand

play30:47

it and comprehend it a bit quicker

play30:48

because you're confirming what you think

play30:51

you're seeing so we think those things

play30:54

that top look like people I guess

play30:55

they're people when you read sex these

play30:58

things look like data storage things

play31:00

down here so and again that the shapes

play31:01

help but fundamentally these diagrams

play31:03

have the same level of information and

play31:05

that information is captured in the text

play31:08

all of this advice goes for icons as

play31:11

well do you ever see people drawing

play31:13

these diagrams with the Amazon AWS icon

play31:17

set or the Azzurri I can set they kind

play31:20

of look pretty and they're great if you

play31:22

want to show all of their own Amazon

play31:24

services you're using but they're

play31:26

basically pointless because I don't

play31:28

understand what half the icons mean and

play31:30

I don't know why these things have been

play31:32

chosen anyway so these diagrams don't

play31:34

tell me enough from a software

play31:35

architecture perspective so what I'm

play31:37

gonna do here is if you do want to use

play31:38

icons feel free but use the icons to

play31:40

again add an additional level or layer

play31:43

of information so here's an alternative

play31:46

version of my inset banking system

play31:47

container diagram now we've removed the

play31:50

color and I'm now using some icons

play31:52

instead so if you know what the icons

play31:55

mean you can see there's a couple of

play31:56

Java spring apps there's a database

play31:57

schema we've got angular and xamarin if

play31:59

you have no idea what the icons mean it

play32:01

doesn't matter because all they're all

play32:02

the informations in in there in the text

play32:04

and your key or your legend should have

play32:07

examples of what those things mean of

play32:08

course and the whole point that this is

play32:10

what what I'm trying to do is make the

play32:12

diagrams able to stand on their own so

play32:17

whenever I see arced it two diagrams you

play32:19

normally have to have a conversation to

play32:20

explain what the diagram means because

play32:22

the diagrams are basically hopeless and

play32:24

that's fine if you're there but often

play32:27

what happens is people draw a diagram on

play32:29

a whiteboard I take a photo stick on

play32:32

confluence and that's where it lives

play32:33

forever more someone new joins your team

play32:36

send them to confluence they have no

play32:38

idea what the diagram means they have to

play32:40

go find the person who drew the diagram

play32:42

Oh guess what they quit four months ago

play32:44

so what we do is we'll spend another

play32:46

three hours with a different group of

play32:47

people at the same whiteboard redrawing

play32:49

the same one not the same picture

play32:51

something that we hope looks like the

play32:53

same sort of picture and we just

play32:55

repeating whistling as I was down any

play33:00

narrative you give any presentation you

play33:02

give any supplementary documentation he

play33:04

write again should tell stories on top

play33:08

of a diagram that already makes sense so

play33:10

what I'm trying to do is I'm trying to

play33:12

make us spend our time telling more

play33:15

valuable stories rather than why's that

play33:17

box blue and this one's red well let's

play33:19

let's just get that stuff down

play33:23

next time you draw a diagram there's a

play33:25

notation checklist you can find at c4

play33:27

model of comets or a single page PDF

play33:29

completely free to download run through

play33:31

this answers them yes-or-no questions

play33:33

and this will hopefully give you some

play33:34

tips on how you can improve your

play33:35

software architecture documents I have a

play33:40

couple of slides left and then we can

play33:41

open the floor for Q&A a lot of people

play33:44

ask me what tooling do I recommend I'm

play33:48

going to give you two recommendations

play33:49

recommendation one I'm gonna give you

play33:52

three recommendations recommendation one

play33:54

do not use Visio and by Visio I mean

play33:59

Visio OmniGraffle lucidchart

play34:02

draw the i/o and Gliffy all of those

play34:04

stuff please do not use them because

play34:05

they're general-purpose diagramming

play34:06

tools and they don't know anything about

play34:08

software architecture so those are the

play34:10

worst categories of tools you can use

play34:12

they're the most common but they're the

play34:13

worst categories of tools you can use so

play34:15

my first recommendation there's a whole

play34:18

bunch of tooling out there for the c4

play34:19

model c4 plant two UML so if you come

play34:22

across plant to your mail it's a way to

play34:24

draw UML diagrams or not I'm using text

play34:28

so you write some text you throw it

play34:30

through a tool and it does automatic

play34:31

layout thing for you so someone created

play34:34

a set of macros a set of plugins for

play34:35

plant UML and they allow you to draw the

play34:37

c4 diagrams using a kind of c4 model ish

play34:41

domain-specific language all complete

play34:44

battle applying UML so that's my

play34:46

recommendation number one recommendation

play34:47

number two is my own tooling sorry so

play34:51

I've been dissatisfied with a lot of the

play34:54

tooling out there for drawing acted two

play34:56

diagrams so I've got a whole bunch of

play34:58

tooling I've built myself some of its

play35:00

free something's open saw some of its

play35:02

commercial but there's a whole bunch

play35:03

tooling out that you can find that helps

play35:04

you draw

play35:05

software architecture diagrams

play35:06

specifically targeted to add the c-4

play35:08

model

play35:09

no matter which tooling you do use

play35:12

abstractions first notation second so if

play35:15

you take this back to your team so

play35:16

anyone to adopt it make sure everybody

play35:18

understands those four levels of

play35:20

abstractions the four key diagram types

play35:22

tell them not to use level four and then

play35:24

just go forward from there and that's me

play35:26

thank you very much

play35:29

[Applause]

Rate This

5.0 / 5 (0 votes)

Related Tags
SoftwareArchitectureC4ModelUMLSimonBrownCommunicationDevelopmentTeamsAgileLeanDiagrammingTechnicalTools