Context
   Mapping in
     action
Stretching the strategic Domain Driven
      Design toolbox to the edge


 alberto.brandolini@avanscoperta.it
About me
Ten years experience
as a consultant,
mainly in large
software
development
projects

Trainer

Blogger

Article Writer
Dropped in a new project
      every time
Foto del garage
Foto del garage




Whatever they told you before
 … reality is a lot different
Foto del garage




Whatever they told you before
   It’s always a mess
 … reality is a lot different
Whatever they told you before
 … reality is a lot different
Choosing Mentors
Choosing Mentors
Choosing Mentors


         “I’m Mr. Wolf.
         I solve problems.”
              Harvey Keitel
“Every battle is won
before it is ever
fought”
            Sun Tzu
“Every battle is won
before it is ever
fought”
             Sun Tzu


“Tactic without
strategy is noise
before defeat”
             Sun Tzu
Know your enemy
Code is not your enemy
  Projects do not fail because of code

Standish group put interaction with the
users and requirements at the top of the
list.

… in a complex scenario, these are often
second order effects
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
A limited resource
       game
Brain cells


Time


Developers


Skills
Enter Context
  Mapping
Context

The setting in which a word or a
    statement appears that
    determines its meaning


          Context
… put in another
       way


A context is a way to measure to which
extent a vision could be effectively shared
Relations

            Context A




Context B
Relations
  Pe o p l
           e of t
  probl           e n so
           e ms           l ve
                  h e re
                         ...
                                 Context A




Context B
Relations
                          Pe o p l
                                   e of t
                          probl           e n so
                                   e ms           l ve
                                          h e re
                                                 ...
                                                         Context A


...o r h
           e re . . .

                        Context B
Relations
                          Pe o p l
                                   e of t
                          probl           e n so
                                   e ms           l ve
                                          h e re
                                                 ...
                                                             Context A


...o r h                                                 ...b u t
           e re . . .                                             the r
                                                         a re s         e al s
                                                                ome w          h o w-
                                                                       h e re         s t o pp
                        Context B                                              in be
                                                                                     t we e    e rs
                                                                                              n!!
Upstream
  Downstream

                Context A

            u
        d

Context B
Whatever they told you before
 … reality is a lot different
Whatever theya difference if
 it does make told you before
  … reality is a lot different
    you’re going upstream
National Geographic,
      take it away
http://www.munseysbearcamp.com/
        Bear_salmon2005.jpg
Patterns

Relations between different contexts tend
to fall into repeatable patterns

A specific pattern dictionary helps to
describe the current situation

Any pattern has a different benefits/costs
ratio.
Anti Corruption Layer
Flexibility: 4/5, Maintenance: 3/5 Ski!s: 3/5 Organization: 1/5
Partnership
Flexibility: 4/5, Maintenance: 2/5 Ski!s: 4/5 Organization: 5/5
Here’s our context
  B ig Ba ll map
      of Mu d
Context                 Context F
   C                                  !
      u                   Context A

                    AC
  d                                pe n
                      L
                    d            O
                                  Hos t
 Context        u
    B               Context         Context
                                       E
                         D
It’s a MAP!
File 1
The very messy
   company
Scenario 1:
Scenario 1:

A shared area among projects
Scenario 1:

A shared area among projects

Good Analysis team but separated from
development
Scenario 1:

A shared area among projects

Good Analysis team but separated from
development

Low interaction with the user
Scenario 1:

A shared area among projects

Good Analysis team but separated from
development

Low interaction with the user

Domain Expert
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
The initial scenario

             Payments
    Enrollment
The initial scenario




                                                         h e ...
                                                      e t or
                                                    ik e f
                                                 s l ag
                                Payments




                                              ok s t
                                           Lo e c t
                                              rf
                                           pe
                       Enrollment
Shared Kernel
Flexibility: 3/5, Maintenance: 2/5, Ski!s: 3/5, Organization: 4/5
The initial stage

                 Legacy
                 Core
             u       u
                     d
         d
Enrollment         Payments
Shall we go for
    DDD?
Shall we go for
       DDD?
Low starting skills
Shall we go for
       DDD?
Low starting skills

Long term project
Shall we go for
       DDD?
Low starting skills

Long term project

Eager to learn
Shall we go for
       DDD?
Low starting skills

Long term project

Eager to learn

A complex domain that calls for
sophisticated modeling
Shall we go for
       DDD?
Low starting skills

Long term project

Eager to learn

A complex domain that calls for
sophisticated modeling

Some developers-analysts already into DDD
“Every battle is won
before it is ever
fought”
             Sun Tzu


“Tactic without
strategy is noise
before defeat”
             Sun Tzu
“Every battle is won
before it is ever
fought” Wrong question
             Sun Tzu


“Tactic without
strategy is noise
before defeat”
             Sun Tzu
The masterplan

                 Legacy
                 Core
             u       u
                      d
         d
Enrollment         Payments
The masterplan

                 Legacy
                 Core
             u       u
                       d
                    A CL
         d
Enrollment          Payments
The masterplan

                 Legacy
                 Core
             u       u
                       d
                    A CL
         d
Enrollment          Payments
The masterplan

                 Legacy
                 Core
             u       u
                       d
                    A CL
         d
Enrollment          Payments
The masterplan

                 Legacy
                 Core
             u       u
                       d
                    A CL
         d
Enrollment          Payments
The masterplan

                 Legacy
                 Core
             u       u
                       d
                    A CL
         d
Enrollment          Payments
The masterplan

                 Legacy
                 Core
             u       u
                       d
                    A CL
         d
Enrollment          Payments
Scenario 1 Update:
Scenario 1 Update:
A freshly written legacy core.
Scenario 1 Update:
A freshly written legacy core.

Distributed development teams
Scenario 1 Update:
A freshly written legacy core.

Distributed development teams

Analysis team separated from development
Scenario 1 Update:
A freshly written legacy core.

Distributed development teams

Analysis team separated from development

  Some teams closely integrated
Scenario 1 Update:
A freshly written legacy core.

Distributed development teams

Analysis team separated from development

  Some teams closely integrated

  Some teams completely disconnected
Scenario 1 Update:
A freshly written legacy core.

Distributed development teams

Analysis team separated from development

  Some teams closely integrated

  Some teams completely disconnected

No interaction with the user
Scenario 1 Update:
A freshly written legacy core.

Distributed development teams

Analysis team separated from development

  Some teams closely integrated

  Some teams completely disconnected

No interaction with the user

Fake Domain Expert
...the chaotic phase

              Legacy
              Core
          u          u
                  u
      d                  d
                   d
                       Payments
    Enrollment
                 Payments
...the chaotic phase

              Legacy
              Core
          u          u
                  u
      d                  d
                   d
                 ACL Payments
    Enrollment
                 Payments
Big Ball of Mud
Flexibility: 1/5, Maintenance: 5/5, Ski!s: 1/5, Organization: 1/5
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                           d
                               Payments
         Enrollment
                        Payments
  Analysis
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                          d
                        ACL Payments
         Enrollment
                        Payments
  Analysis
Exposing the bare
                  truth
          Integration             Legacy
                                  Core
                              u          u
                                      u
Th i t
 Ub
  is o u




                                             d
    iq u




                          d
     is s
         AW L a




                                       d
           FU u




                                     ACL Payments
             L ! ag
                ng




                        Enrollment
                 No e




                                     Payments
              Analysis
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                           d
                               Payments
         Enrollment
                        Payments
  Analysis
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                          d
                        ACL Payments
         Enrollment
                        Payments
  Analysis
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                          d
                        ACL Payments
         Enrollment
                        Payments
  Analysis
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                          d
                        ACL Payments
         Enrollment
                        Payments
  Analysis
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                          d
                        ACL Payments
         Enrollment
                        Payments
  Analysis
Exposing the bare
      truth
Integration           Legacy
                      Core
                  u          u
                          u
              d                  d
                          d
                        ACL Payments
         Enrollment
                        Payments
  Analysis
Exposing the truth
Exposing the truth
Ultimately, Sun Tzu war right:

  though Entities, Value Objects, Aggregates
  etc. proved successful within their scope...

  ...That was ultimately not relevant in the
  large scale

Exposing the truth via Context Mapping
was relevant and led to major changes in
management
File 2
The Strangelove
   Scenario
      M.A.D.
Scenario 2:

Large government project

Many different actors involved

Great development team

Domain was not the primary focus of the
project
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Our game set
Money


Brain


Time


Developers


Skills
Not the perfect
  stage for DDD
Complex domain but outside our project
scope

Focus on technology:

 Reliability

 Security

 Performance
Our Stage

                   Agency A
           u
  X-Team
    (us)
               u
                   Agency B
           u

                   Agency C
Our Plan

                                      pp l ie r   Agency A
                                  u
                            e r/s
                     us t om
                 c

      X-Team               pe n
Op e n (us)              O
H os t                    Hos t                   Agency B

      Publ i s
     L angu    he d
              ag e
                                                  Agency C
Our Stage

            Agency A


  X-Team
    (us)    Agency B


   “the
  others”   Agency C
Our Stage

                    Agency A


  X-Team
    (us)       It’s a Agency B
            partnership

   “the
  others”           Agency C
Photo courtesy of Rajarshi Roychowdhury
Choosing Mentors
Choosing Mentors




“???”
              “Franco” Begbie
Choosing Mentors

                   e d
              a r d
         i s c
“???”
        D
                 “Franco” Begbie
Cockfight
Flexibility: 0/5, Maintenance: 5/5 Ski!s: 0/5 Organization: 0/5
e d
                     a r d
                i s c
        D Cockfight
Flexibility: 0/5, Maintenance: 5/5 Ski!s: 0/5 Organization: 0/5
Didn’t need any new
      pattern
 Despite my idea of “getting rich selling the
 Strategic DDD Expansion Set”, we didn’t
 need any new pattern

 Team was trapped in a Downstream
 Position

 “Official partnership” forced us to be
 conformist to an unreliable external team
Conformist
Flexibility: 1/5, Maintenance: 4/5 Ski!s: 2/5 Organization: 2/5
Step 1
Protect our
application from     X-Team
external influences     (us)
by introducing an      ACL
Anti Corruption        d

Layer (no                  u

Conformist any        “the
                     others”
more)
Step 2


     focus all
     energies to go
     upstream
Step 2


            focus all
            energies to go
            upstream


Step 2: go upstream
Going upstream
Going upstream

published and reliable planning
Going upstream

published and reliable planning

continuous integration
Going upstream

published and reliable planning

continuous integration

steady pace
Going upstream

published and reliable planning

continuous integration

steady pace

effective partnership
Going upstream

published and reliable planning

continuous integration

steady pace

effective partnership

jacket & tie
Project outcome

Reversing the relationship had a positive
outcome on all relationships

Context Map exposed the right thing to do

Delivered on time and on budget

Benchmark for following projects
Some years later
Overall project now seen as critical:

  it’s working perfectly (technology)...

  ...but it’s not doing the right thing.



No user-driven evolution

Importance of domain model largely
underestimated
File 3
...Not another
  framework,
     please
Scenario 3:

Government backed (baked) project

A “platform” upon which build many
“services”

Many different players

A Family of similar projects in different
locations
Payment
                           Services
   School




                              er
   Services




                              li
                           pp
                                      Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                         Down (conformist)




             Up
Payment
                           Services
   School




                              er
   Services




                              li
                           pp
                                      Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                         Down (conformist)




             Up




 Framework
Payment
                           Services
   School




                              er
   Services




                              li
                           pp
                                      Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                         Down (conformist)




             Up




 Framework
Payment
                                Services
   School




                                  er
   Services




                                   li
                                pp
                                           Certificates




                                Su
                            r-
                          me
                         s to
Down (conformist)




                     Cu
                                              Down (conformist)




             Up

                    Up


 Framework
Payment
                                     Services
   School




                                       er
   Services




                                        li
                                     pp
                                                Certificates




                                     Su
                                 r-
                               me
                              s to
Down (conformist)




                          Cu
                                                   Down (conformist)




             Up     Up
                         Up


 Framework
Payment
                           Services
                                                               m i s t)
                                                       o   r
                                                  o nf
   School                           Do w
                                           n   (c




                              er
   Services




                              li
                           pp
                                                     Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                                                          Down (conformist)




                                     Up                            Up
                              Up

                                   Domain
                                   Model
Framework
Payment
                           Services
                                                               m i s t)
                                                       o   r
                                                  o nf
   School                           Do w
                                           n   (c




                              er
   Services




                              li
                           pp
                                                     Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                                                          Down (conformist)




                                     Up                            Up
                              Up

                                   Domain
                                   Model
Frameworkk
 Fram ewor
Payment
                           Services
                                                               m i s t)
                                                       o   r
                                                  o nf
   School                           Do w
                                           n   (c




                              er
   Services




                              li
                           pp
                                                     Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                                                          Down (conformist)




                                     Up                            Up
                              Up

                                   Domain
                                   Model
Frameworkk
Framework
 Fram ewor
Payment
                           Services
                                                               m i s t)
                                                       o   r
                                                  o nf
   School                           Do w
                                           n   (c




                              er
   Services




                              li
                           pp
                                                     Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                                                          Down (conformist)




                                     Up                            Up
                              Up

                                   Domain
                                   Model
Frameworkk
Framework
 Fram ewor
Payment
                           Services
                                                               m i s t)
                                                       o   r
                                                  o nf
   School                           Do w
                                           n   (c




                              er
   Services




                              li
                           pp
                                                     Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                                                          Down (conformist)




                                     Up                            Up
                              Up

                                   Domain
                                   Model
                           Up
Frameworkk
Framework
 Fram ewor
Payment
                           Services
                                                               m i s t)
                                                       o   r
                                                  o nf
   School                           Do w
                                           n   (c




                              er
   Services




                              li
                           pp
                                                     Certificates




                           Su
                         r-
                     me
                    s to
Down (conformist)




                    Cu
                                                                          Down (conformist)




                                     Up                            Up
                              Up

                                   Domain
                                   Model
                           Up                                                    Thi s
Frameworkk
Framework
      ewor                                                                sh o u       defin
 Fram                                                                            ldn’t      i te l y
                                                                                       be lik
                                                                                              e t hi
                                                                                                     s!!
The plan
Consolidation of reference framework

  darwinian selection of features

  intensive testing

  wrapping existing features with ACLs

releasing constraints on the application side

  domain --> published language

  freedom of choice, allowing different paradigms
… no outcome yet,
      but...
Context mapping is driving the strategic
decision process

  Map of the current situation (as far as we
  know it)

  Base for a pragmatic action plan

  Exposes the hot spots
Conclusions
Our context map
      Big Ba l l
       of Mu d
Context                    Context F
   C                                     !
      u                      Context A

                       AC
  d                                   pe n
                         L
                       d            O
                                     Hos t
 Context           u
    B                  Context         Context
                                          E
                            D
It’s a MAP!
It’s a MAP

This is where battles are win before they’re
fought

  Taking advantage of the landscape

  concentrating our forces where it does
  matter

  avoiding to fight if the odds are against us
Not only for the
       elite
Context mapping has a broader scope of
application than tactical DDD

 far from ideal scenario

 disconnected environments…

 … you got the idea…

Might tell you whether to go for DDD or
not
...Should be easy to
      draw...
...Should be easy to
      draw...

...but if it’s not, you’re already getting
some very useful information

Sometimes the process of gathering
information to draw the context map is
more important than the map itself
Software mirrors
 organizations
Organizational
 Dysfunctions
Organizational
     Dysfunctions
Context Mapping often exposes the gap
between the ideal communication flow and
the real one.
Organizational
     Dysfunctions
Context Mapping often exposes the gap
between the ideal communication flow and
the real one.

...and this is often in the grey area where
nobody is responsible for anything and
things simply happen.
Organizational
     Dysfunctions
Context Mapping often exposes the gap
between the ideal communication flow and
the real one.

...and this is often in the grey area where
nobody is responsible for anything and
things simply happen.

How much does this cost to share a
vision?
search - see - expose
search - see - expose
 Context Mapping gave great insights
 allowing us to do the right thing.
search - see - expose
 Context Mapping gave great insights
 allowing us to do the right thing.

 Did we discover new things?
search - see - expose
 Context Mapping gave great insights
 allowing us to do the right thing.

 Did we discover new things?

  Many things were “there” simply floating
  in the nobody’s land between a context
  and another.
search - see - expose
 Context Mapping gave great insights
 allowing us to do the right thing.

 Did we discover new things?

  Many things were “there” simply floating
  in the nobody’s land between a context
  and another.

  Context mapping helped us see the
  whole picture early and clearly.
Thanks



more on http://ziobrando.blogspot.com

twitter: ziobrando

Context Mapping In Action