Aligning Bounded Contexts with
Subdomains in Legacy Code
NDC Oslo 2021
Mufrid Krilic
Domain-Driven Design Coach
www.cowork.no
Training and
Coaching
• Agile Leadership
• “Tight-Loose-Tight”
• Domain-Driven Design with NDC
Workshops
• bit.ly/domainstorytelling-online
• Blog
• https://mufridk.medium.com
Book recommendation #1
Strategic Domain-Driven
Design
The Principles
Strategic DDD
• Focusing on Core domain
• Problem and solution space
• Subdomains and Bounded Contexts
• Linguistic boundaries
• Ubiquitous Language
• The two pillars of DDD
Core Domain
• The thing that distinguishes you
from the competitors
• “Not every part of the system will be
well-designed”
• Generic subdomain
• Supporting subdomain
Problem Space
and
Solution Space
Problem space
• Domain analysis to discover
inherent Subdomains
Solution space
• Model your application accordingly
in multiple Bounded Contexts
Linguistic
Boundaries
Ubiquitous Language
• The same language everywhere
• Conversations
• Documentation
• Code
The Two Pillars of
DDD
1. Ubiquitous Language
2. Bounded Context
Bounded contexts in your application
are defined by linguistic boundaries
Book recommendation #2
Boundaries
Why?
Making Sense of
the Problem
Space
• Aligning with the business
• Reducing the translation effort
• Ubiquitous Language
Reducing the
Cognitive Load
• Legacy Code
• Being able to navigate
• …. and understand
• Hidden boundaries in legacy code
• Look for subdomains
Book recommendation #3
Boundaries
Where?
Observable
boundaries
• Technical
• Network
• Containers
• Organizational
• Teams
• Departments
• Easily observable boundaries
Not so easily
observable?
• The “4+1” View Model of Software
Architecture
• Philippe Kruchten
• https://bit.ly/4plus1Paper
https://bit.ly/4plus1Paper
Dependencies
What are they?
Logical View
Dependencies
The reason for increased coupling
• The amount of data that is passed
across the boundaries
Cost of
Dependencies in a
Distributed System
• Distributed logical dependencies
• Across software and process views
• Across the organization
• Microservices
The Story Begins….
Story about a team dealing with legacy system
Business Case
• Physicians prescribe medications
• Integration with systems for
prescription delivery in pharmacies
• Focus on putting patient needs and
safety on the top
Use Case
Prescribing pre-approved medication
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Drawn with egon.io
Use Case
Prescribing non-approved medication
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Drawn with egon.io
Book recommendation #4
Looking for Subdomains
.... in Legacy Environments
Subdomains in
Problem Space
• Pivotal Event
• NonApprovedMedicationPrescribed
• Time-related activity
• While waiting for approval the
physician stops the prescription
process
Drawn with egon.io
Traces of Bounded
Contexts in
Development View
• Are there any established
boundaries in the Development
View?
• 4+1 Model
• .NET projects
• Namespaces
Dependencies in
Logical View
• Analysis of
• using statements
• .NET project references
• NuGet package references
• Http calls to remote services
• Event-based communication with
remote services
Bounded Contexts
…. and Context Mapping
DDD Context Mapping
Downstream: depending on upstream
Upstream: depended on downstream
Conformist: Upstream model referenced directly in Downstream context
Bounded Contexts
in Legacy Code
• Respect existing dependencies and
relationships
• Explicit decision on the amount of
work needed to break things up
Decision Time
Application
Bounded Context
• Establish observable boundary
• Visual Studio Solution
• Prescription Bounded Context
remains as is
• 1 week time-box
• Summarize lessons learned
regardless of the outcome
Step One
Establish Visual Studio Solution
Move existing .NET projects
• Between solutions within the same repository
• git mv
• Exclude/Include Project
Code compiles and unit tests run
Integration tests?
• Valuable enough feedback with unit
tests only?
• Integration/E2E tests
• Harder to maintain
• Can provide runtime feedback
Work on E2E tests?
• Pros
• Early feedback on bounded context/subdomain alignment
• Cons
• Considerable work needed just to get the tests running
• Could actually slow down the feedback loop
Focus on unit tests only at this stage
Step Two
Cleaning up obsolete references
Made obsolete in step one
• .NET project references
• using statements
Uncovers hidden dependencies
Classes and interfaces
- Defined in Application BC
- Referenced in Prescription BC
Stable Abstraction
Principle
Packages that are maximally
stable should be maximally
abstract.
• Extract common type definitions to
a separate module
DDD Context Mapping
Shared Kernel: Two contexts share a subset of the domain model
Step 3
Make E2E tests to run
The end of the story….
• Some E2E tests in Prescription context required DLLs from
Application context
• Why?
Valid business reason for Prescription BC to refer to Application BC
- Beware of Circular Dependencies!
Business requirement unlocked
• As a physician while prescribing a non-approved medicament
• I need to see prior applications for the same medicament
• To be able to prescribe non-approved medicaments on a life-long
basis if required by patient condition
Requires dependency from Prescription BC to Application BC
Can we avoid
circular
dependencies?
• 4+1 model
• Deployment dependencies ok
• Circular logical dependencies
• All the integration tests in one
module
• Referencing different bounded
contexts
• All DLLs would be available
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
View Model
Composition • Composing data from different
Bounded Contexts on front-end
• Suggested reading
• Mauro Servienti
• https://milestone.topics.it/
• The physician needs only to see the
prior applications
• Data shown for decision-support
Takeaways for the Team
▪ Regular Architectural Reviews
– continuous learning about subdomain boundaries
▪ Stable Abstraction Principle
– Define desired relationships between the modules
▪ Discover Logical Dependencies in Code Review
– 4+1 Model
▪ “You can always make things more cohesive”
– Kent Beck
Ella Fitzegerald –
«They Cant’t Take That Away From Me»
Book recommendation #5
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021
Photos
• By !Original: MddVector: Wikimpan - Based on File:4+1 Architectural View Model.jpg by User:Mdd, CC BY-SA 3.0,
https://commons.wikimedia.org/w/index.php?curid=50144028
• https://unsplash.com/@renemolenkamp
• https://unsplash.com/@jancanty
• https://unsplash.com/@afafa
• https://unsplash.com/@walkator
• https://unsplash.com/@woutvanacker
• https://unsplash.com/@polarmermaid
• https://unsplash.com/@cdd20
• https://unsplash.com/@roaming_angel
• https://unsplash.com/@micheile
• https://unsplash.com/@patrickperkins
• https://unsplash.com/@melany_tuinfosalud
• https://unsplash.com/@timmossholder

More Related Content

PPTX
Building Quality in Legacy Systems - The Art of Asking Questions, JavaZone VR...
DOC
Raghav_CDM-Exp_4.5yrs
DOC
Vinoth_Resume
DOC
Harsha
PPTX
Fractional differential equations Assignment Help and Fractional differential...
PDF
PhD Proposal talk
DOCX
Vijayakrishna_testing_manual_selenium (1)
DOC
Resume testing
Building Quality in Legacy Systems - The Art of Asking Questions, JavaZone VR...
Raghav_CDM-Exp_4.5yrs
Vinoth_Resume
Harsha
Fractional differential equations Assignment Help and Fractional differential...
PhD Proposal talk
Vijayakrishna_testing_manual_selenium (1)
Resume testing

What's hot (12)

DOC
Clinical Data Co-ordinator
PPT
Make the Most of Your Time: How Should the Analyst Work with Automated Tracea...
PDF
Pipeline
PPT
Project Data Incorporating Qualitative Factors for Improved Software Defect P...
PPT
Agile Software Security
PDF
Introduction to Non Functional Requirement (NFR)
PPTX
Software Architecture
PDF
A Metric for Code Readability
PDF
Non-Functional Requirements
PPTX
Presentation Slides For Agile Review
DOC
Java Software Developer Opportunity
PPTX
FedViz: A Visual Interface for SPARQL Queries Formulation and Execution
Clinical Data Co-ordinator
Make the Most of Your Time: How Should the Analyst Work with Automated Tracea...
Pipeline
Project Data Incorporating Qualitative Factors for Improved Software Defect P...
Agile Software Security
Introduction to Non Functional Requirement (NFR)
Software Architecture
A Metric for Code Readability
Non-Functional Requirements
Presentation Slides For Agile Review
Java Software Developer Opportunity
FedViz: A Visual Interface for SPARQL Queries Formulation and Execution
Ad

Similar to Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021 (20)

PPTX
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
PPTX
Domain Driven Design
PDF
Domain Driven Design - Distillation - Chapter 15
PPTX
Schibsted Spain - Day 1 - DDD Course
PPTX
Software Engineering - Trends & Industry Practices
PPTX
Art of refactoring - Code Smells and Microservices Antipatterns
PPTX
Feedback on DDD Europe - short -event storming.pptx
PDF
Domain Driven Design Big Picture Strategic Patterns
PDF
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013
PPTX
Got documents - The Raven Bouns Edition
PPT
Domain Driven Design (DDD)
PDF
Domain Driven Design - Building Blocks
PPTX
Ddd boundaries & responsibilities
PPTX
Domain Driven Design
PPTX
Richard Wilburn - Lean Truth
PPTX
Introduction to DDD
PPTX
Dependency injection via annotations v1.0
PPTX
Got documents Code Mash Revision
PPTX
Dbms fast track 3/3
PPTX
Cucumber is a Behavior Driven Development tool used to develop test cases for...
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Domain Driven Design
Domain Driven Design - Distillation - Chapter 15
Schibsted Spain - Day 1 - DDD Course
Software Engineering - Trends & Industry Practices
Art of refactoring - Code Smells and Microservices Antipatterns
Feedback on DDD Europe - short -event storming.pptx
Domain Driven Design Big Picture Strategic Patterns
Neo4j Theory and Practice - Tareq Abedrabbo @ GraphConnect London 2013
Got documents - The Raven Bouns Edition
Domain Driven Design (DDD)
Domain Driven Design - Building Blocks
Ddd boundaries & responsibilities
Domain Driven Design
Richard Wilburn - Lean Truth
Introduction to DDD
Dependency injection via annotations v1.0
Got documents Code Mash Revision
Dbms fast track 3/3
Cucumber is a Behavior Driven Development tool used to develop test cases for...
Ad

More from Mufrid Krilic (8)

PDF
Multiple Models with Multiple Perspectives in a Cross-Functional Team - KanDD...
PPTX
Dataeierskap som grunnlag for applikasjonsutvikling - Make Data Smart Trondhe...
PDF
Domain storytelling – facilitator’s guide to enhance learning in your organiz...
PDF
Building Quality in Legacy Systems - The Art of Asking Questions
PDF
Domain model in Multi-language Environment With Examples from Healthcare
PPTX
Domain storytelling
PPTX
Strategies to learn complex domains - Experiences from Developing Enterprise ...
PPTX
Motivate! Do Not Teach - FIRST Championship Conferences Detroit 2018
Multiple Models with Multiple Perspectives in a Cross-Functional Team - KanDD...
Dataeierskap som grunnlag for applikasjonsutvikling - Make Data Smart Trondhe...
Domain storytelling – facilitator’s guide to enhance learning in your organiz...
Building Quality in Legacy Systems - The Art of Asking Questions
Domain model in Multi-language Environment With Examples from Healthcare
Domain storytelling
Strategies to learn complex domains - Experiences from Developing Enterprise ...
Motivate! Do Not Teach - FIRST Championship Conferences Detroit 2018

Recently uploaded (20)

PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PPTX
Computer Software - Technology and Livelihood Education
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
Website Design Services for Small Businesses.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Cost to Outsource Software Development in 2025
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
Introduction to Windows Operating System
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Types of Token_ From Utility to Security.pdf
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
Monitoring Stack: Grafana, Loki & Promtail
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Topaz Photo AI Crack New Download (Latest 2025)
Computer Software - Technology and Livelihood Education
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Website Design Services for Small Businesses.pdf
iTop VPN Crack Latest Version Full Key 2025
Cost to Outsource Software Development in 2025
Tech Workshop Escape Room Tech Workshop
GSA Content Generator Crack (2025 Latest)
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Introduction to Windows Operating System
How to Use SharePoint as an ISO-Compliant Document Management System
Types of Token_ From Utility to Security.pdf
Time Tracking Features That Teams and Organizations Actually Need
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Oracle Fusion HCM Cloud Demo for Beginners
Computer Software and OS of computer science of grade 11.pptx
Monitoring Stack: Grafana, Loki & Promtail

Aligning Bounded Contexts with Subdomains in Legacy Code - NDC Oslo 2021

  • 1. Aligning Bounded Contexts with Subdomains in Legacy Code NDC Oslo 2021 Mufrid Krilic Domain-Driven Design Coach www.cowork.no
  • 2. Training and Coaching • Agile Leadership • “Tight-Loose-Tight” • Domain-Driven Design with NDC Workshops • bit.ly/domainstorytelling-online • Blog • https://mufridk.medium.com
  • 5. Strategic DDD • Focusing on Core domain • Problem and solution space • Subdomains and Bounded Contexts • Linguistic boundaries • Ubiquitous Language • The two pillars of DDD
  • 6. Core Domain • The thing that distinguishes you from the competitors • “Not every part of the system will be well-designed” • Generic subdomain • Supporting subdomain
  • 7. Problem Space and Solution Space Problem space • Domain analysis to discover inherent Subdomains Solution space • Model your application accordingly in multiple Bounded Contexts
  • 8. Linguistic Boundaries Ubiquitous Language • The same language everywhere • Conversations • Documentation • Code
  • 9. The Two Pillars of DDD 1. Ubiquitous Language 2. Bounded Context Bounded contexts in your application are defined by linguistic boundaries
  • 12. Making Sense of the Problem Space • Aligning with the business • Reducing the translation effort • Ubiquitous Language
  • 13. Reducing the Cognitive Load • Legacy Code • Being able to navigate • …. and understand • Hidden boundaries in legacy code • Look for subdomains
  • 16. Observable boundaries • Technical • Network • Containers • Organizational • Teams • Departments • Easily observable boundaries
  • 17. Not so easily observable? • The “4+1” View Model of Software Architecture • Philippe Kruchten • https://bit.ly/4plus1Paper
  • 20. Logical View Dependencies The reason for increased coupling • The amount of data that is passed across the boundaries
  • 21. Cost of Dependencies in a Distributed System • Distributed logical dependencies • Across software and process views • Across the organization • Microservices
  • 22. The Story Begins…. Story about a team dealing with legacy system
  • 23. Business Case • Physicians prescribe medications • Integration with systems for prescription delivery in pharmacies • Focus on putting patient needs and safety on the top
  • 39. Looking for Subdomains .... in Legacy Environments
  • 40. Subdomains in Problem Space • Pivotal Event • NonApprovedMedicationPrescribed • Time-related activity • While waiting for approval the physician stops the prescription process
  • 42. Traces of Bounded Contexts in Development View • Are there any established boundaries in the Development View? • 4+1 Model • .NET projects • Namespaces
  • 43. Dependencies in Logical View • Analysis of • using statements • .NET project references • NuGet package references • Http calls to remote services • Event-based communication with remote services
  • 44. Bounded Contexts …. and Context Mapping
  • 45. DDD Context Mapping Downstream: depending on upstream Upstream: depended on downstream Conformist: Upstream model referenced directly in Downstream context
  • 46. Bounded Contexts in Legacy Code • Respect existing dependencies and relationships • Explicit decision on the amount of work needed to break things up
  • 48. Application Bounded Context • Establish observable boundary • Visual Studio Solution • Prescription Bounded Context remains as is • 1 week time-box • Summarize lessons learned regardless of the outcome
  • 49. Step One Establish Visual Studio Solution
  • 50. Move existing .NET projects • Between solutions within the same repository • git mv • Exclude/Include Project Code compiles and unit tests run
  • 51. Integration tests? • Valuable enough feedback with unit tests only? • Integration/E2E tests • Harder to maintain • Can provide runtime feedback
  • 52. Work on E2E tests? • Pros • Early feedback on bounded context/subdomain alignment • Cons • Considerable work needed just to get the tests running • Could actually slow down the feedback loop Focus on unit tests only at this stage
  • 53. Step Two Cleaning up obsolete references
  • 54. Made obsolete in step one • .NET project references • using statements Uncovers hidden dependencies
  • 55. Classes and interfaces - Defined in Application BC - Referenced in Prescription BC
  • 56. Stable Abstraction Principle Packages that are maximally stable should be maximally abstract. • Extract common type definitions to a separate module
  • 57. DDD Context Mapping Shared Kernel: Two contexts share a subset of the domain model
  • 58. Step 3 Make E2E tests to run
  • 59. The end of the story…. • Some E2E tests in Prescription context required DLLs from Application context • Why?
  • 60. Valid business reason for Prescription BC to refer to Application BC - Beware of Circular Dependencies!
  • 61. Business requirement unlocked • As a physician while prescribing a non-approved medicament • I need to see prior applications for the same medicament • To be able to prescribe non-approved medicaments on a life-long basis if required by patient condition Requires dependency from Prescription BC to Application BC
  • 62. Can we avoid circular dependencies? • 4+1 model • Deployment dependencies ok • Circular logical dependencies • All the integration tests in one module • Referencing different bounded contexts • All DLLs would be available
  • 64. View Model Composition • Composing data from different Bounded Contexts on front-end • Suggested reading • Mauro Servienti • https://milestone.topics.it/ • The physician needs only to see the prior applications • Data shown for decision-support
  • 65. Takeaways for the Team ▪ Regular Architectural Reviews – continuous learning about subdomain boundaries ▪ Stable Abstraction Principle – Define desired relationships between the modules ▪ Discover Logical Dependencies in Code Review – 4+1 Model ▪ “You can always make things more cohesive” – Kent Beck Ella Fitzegerald – «They Cant’t Take That Away From Me»
  • 70. Photos • By !Original: MddVector: Wikimpan - Based on File:4+1 Architectural View Model.jpg by User:Mdd, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=50144028 • https://unsplash.com/@renemolenkamp • https://unsplash.com/@jancanty • https://unsplash.com/@afafa • https://unsplash.com/@walkator • https://unsplash.com/@woutvanacker • https://unsplash.com/@polarmermaid • https://unsplash.com/@cdd20 • https://unsplash.com/@roaming_angel • https://unsplash.com/@micheile • https://unsplash.com/@patrickperkins • https://unsplash.com/@melany_tuinfosalud • https://unsplash.com/@timmossholder