is DDD? ▪ Knowledge Crunching ▪ Strategic Design based on Bounded Contexts ▪ Strategic Design based on Subdomains ▪ Context Mapping ▪ Ubiquitous Language ▪ Developing the Domain Model ▪ Tactical Design based on Building Blocks ▪ Optional ▪ Implementing the Building Blocks ▪ Design by Contract
SILHOUETTE on SOUNDING SERVICE SOUNDING SHIP DEPTH 1 2 to 3 4 5 DEPTH MAP 8 SHIP‘S SILHOUETTE and finds 9 reports back to 6 ROUTE ROUTE DEPTH MAP DEPTH MAP RECORDED DEPTHS ROUTE CONTOUR LINE
SOUNDING SERVICE SOUNDING SHIP DEPTH 1 2 to 3 4 5 DEPTH MAP 8 SHIP‘S SILHOUETTE and finds 9 reports back to 6 ROUTE ROUTE DEPTH MAP DEPTH MAP RECORDED DEPTHS ROUTE CONTOUR LINE SMALL
on SOUNDING SERVICE SOUNDING SHIP DEPTH 1 2 to 3 4 5 DEPTH MAP 8 SHIP‘S SILHOUETTE and finds 9 reports back to 6 ROUTE ROUTE DEPTH MAP DEPTH MAP RECORDED DEPTHS ROUTE CONTOUR LINE
on SOUNDING SERVICE SOUNDING SHIP DEPTH 1 2 to 3 4 5 DEPTH MAP 8 SHIP‘S SILHOUETTE and finds 9 reports back to 6 ROUTE ROUTE DEPTH MAP DEPTH MAP RECORDED DEPTHS ROUTE CONTOUR LINE
is way better than no example at all "Because sometimes three good examples are better for understanding the requirements than a bad abstraction." Peter Hruschka in Busines Analysis und Requirements Engineering, S.102, Hanser, 2014
ft« SOUNDED DEPTH COLORED »RED« EVENT A RELEVANT DOMAIN EVENT Something happened here that GETS US FURTHER from a domain perspective! DEPTH »10 ft« SOUNDED DEPTH COLORED »RED«
3 WPS – Workplace Solutions ▪ Our brain is far too tiny to understand the world as a whole! ▪ This is why we develop models ➢ we abstract ➢ we keep relevant stuff ➢ we drop irrelevant stuff HOW TO UNDERSTAND THE WORLD ? Foto: Maiconfz/pixabay/ CC0 Foto: Wikipedia/CC-PD 03.09.2020 //// Seite 4 WPS – Workplace Solutions WHEN OBSERVING A BASKETBALL GAME: DON‘T MIND THE GORILLA!
5 WPS – Workplace Solutions MULTIPLE MODELS / SMALLER MODELS Foto: Maiconfz/pixabay/CCO Foto: Globus from book shelf/wikipedia/ CC-BY-3.0 Foto:Clker-Free-Vector-Images/pixabay/ CCO Foto: Wasserseemüller-Globus/Wikipedia/CC-PD-Mark 03.09.2020 //// Seite 6 WPS – Workplace Solutions ▪ »Newton was a genius, but not because of the superior computational power of his brain. Newton's genius was, on the contrary, his ability to simplify, idealize, and streamline the world so that it became, in some measure, tractable to the brains of perfectly ordinary men.« – Jerry Weinberg ISAAC NEWTON AND MODELS
7 WPS – Workplace Solutions HOW TO UNDERSTAND THE DOMAIN AND BUILD SOFTWARE FOR IT ? ▪ Classic approach: ▪ Integrated monolithic software that takes care of anything a user could reasonably wish for! ▪ Central data base! ▪ Hope: ▪ Problems are solved once and for all! ▪ No redundant data! @hschwentner »Whoever uses a company-wide domain model has lost control over his life« – Karl Lagerfeld
9 WPS – Workplace Solutions ▪ Multiple mixed-up mental models ▪ Unhandable amount of complexity ▪ Whack-the-mole side effects ▪ Dependencies among teams CLASSIC DOMAIN MODEL – REALITY CHECK Foto: CMS Higgs-even/Wikipedia/CC-BY-SA-3.0 03.09.2020 //// Seite 10 WPS – Workplace Solutions ▪ Usually the domain is to large to comprehend as a whole. ▪ Develop multiple smaller models. ▪ Build multiple smaller pieces of software – one for each model! HOW TO UNDERSTAND THE DOMAIN AND BUILD SOFTWARE FOR IT ?
13 WPS – Workplace Solutions BOUNDED CONTEXTS ▪ Each model has its own context ▪ Context = Environment that provides domain terms with a specific meaning! ▪ Set explicit boundaries in ▪ team organisation ▪ code base ▪ data base schemes ▪ (source code) ▪ (deployment units) Foto: Bundesarchiv, Bild 173-1282/Helmut J. Wolf/Wikipedia/CC-BY-SA 3.0 IDENTIFYING SUBDOMAINS (aka „CUTTING THE DOMAIN“)
15 WPS – Workplace Solutions FIND THE POINTS OF NO RETURN 03.09.2020 //// Seite 16 WPS – Workplace Solutions @JoernKoch POINTS OF NO RETURN Which domain events complete a sub-process with a working result that persists?
31 WPS – Workplace Solutions IDENTIFY THE SUBDOMAINS DEPTH ft« SOUNDED DEPTH COLORED »RED« 03.09.2020 //// Seite 32 WPS – Workplace Solutions IDENTIFY THE SUBDOMAINS DEPTH ft« SOUNDED DEPTH COLORED »RED« Tip: It‘s rather easy to name sub-processes. Go with those names and name subdomains correspondingly.
33 WPS – Workplace Solutions SAVE THE RESULTS! 03.09.2020 //// Seite 34 WPS – Workplace Solutions PRACTICE: Find the points of no return and identify the cinema’s subdomains.
7 SHIP‘S SILHOUETTE on SOUNDING SERVICE SOUNDING SHIP DEPTH 1 2 to 3 4 5 DEPTH MAP 8 SHIP‘S SILHOUETTE and finds 9 reports back to 6 ROUTE ROUTE DEPTH MAP DEPTH MAP RECORDED DEPTHS ROUTE CONTOUR LINE DEPTH SOUNDING MANEUVER- PLANNING Group the steps: • Draw a boundary around activities and work objects. • Leave acteurs outside. Find a name for the sub domain places NAVIGATOR CAPTAIN 7 SHIP‘S SILHOUETTE on SOUNDING SERVICE SOUNDING SHIP DEPTH 1 2 to 3 4 5 DEPTH MAP 8 SHIP‘S SILHOUETTE and finds 9 reports back to 6 ROUTE ROUTE DEPTH MAP DEPTH MAP RECORDED DEPTHS ROUTE CONTOUR LINE DEPTH SOUNDING MANEUVER- PLANNING Determine the parts of the subdomain that you actually want to build a software for (e. g. an MVP). Build a Bounded Context just for those.
37 WPS – Workplace Solutions Common heuristics: ▪ Points of no Return (persistent work results) ▪ Borders within the process ▪ State changes, that affect the „nature“ of an aggregate (e. g. „contract legally binding“, „shopping cart ordered“) ▪ Departments of the organisation ▪ Contextual language ▪ Different usage of entities / aggregates ▪ NOT: by entities / aggregates! HOW TO CUT THE DOMAIN? Foto: Wikipedia/PD-ScottForesman 03.09.2020 //// Seite 39 WPS – Workplace Solutions <<Aggregate>> DepthMap place(silhouette) send() places NAVIGATOR SHIP‘S SILHOUETTE on SOUNDING SERVICE DEPTH MAP DEPTH MAP
WPS – Workplace Solutions PROBLEM SPACE VS SOLUTION SPACE ▪ Problem Space: ▪ Focus on business challenges. ▪ Pure domain logic. ▪ The domain consists of 1-n subdomains. ▪ Solution space: ▪ Focus on how to implement the software that helps us tackling business challenges. ▪ Based on specific technology. ▪ The software consists of 1-n bounded contexts. ▪ Each based on a subdomain-specific domain model. Foto: gerat/pixabay/CC0 03.09.2020 //// Seite 5 WPS – Workplace Solutions SUBDOMAINS ▪ The parts the domain consists of ▪ Separation of business concerns ▪ Already there (not to be designed) ▪ Problem space Foto: Wikipedia/CC BY-SA 2.5
WPS – Workplace Solutions BOUNDED CONTEXT VS SUBDOMAIN ▪ In greenfield software development BC and subdomain match 1:1. ▪ Whereas, in a greenfield startup phase the BC will probably not cover all parts of the subdomain it relates to. ▪ In brownfield software development mismatches are common (e. g. 1 system for n problems, n systems for 1 problem, overlapping / duplicate / missing responsibilities) ▪ Legacy systems often are »Unbounded Contexts« Two sides of a medal Foto: Dreibund Medaille/Wikipedia/CC BY-SA 3.0 03.09.2020 //// Seite 7 WPS – Workplace Solutions TIDE FORECAST DEPTHS SOUNDING MANEUVER PLANNING @ HAMBURG PORT: SUBDOMAINS == BOUNDED CONTEXTS TIDE FORECAST DEPTHS SOUNDING Subdomain Bounded Context
WPS – Workplace Solutions BILLING & INVOICE SUBDOMAINS / DEPARTMENTS VS BOUNDED CONTEXTS PAYMENT ACCOUNTING ▪ Intended is a 1:1 match of systems and subdomains ▪ Usually impossible in a brownfield environment. ▪ Can be impossible in a greenfield environment, too, because: ▪ (Unbounded) standard software must be used ▪ Technical reasons Subdomain BC / (3rd-party) system SALES 03.09.2020 //// Seite 9 WPS – Workplace Solutions MISMATCH: SYSTEMS vs SUBDOMAINS BIG BALL OF PAIN CORE MASTER BI SHIPPING ARTICLES TEAM STOCK TEAM BI TEAM SALES @JoernKoch
WPS – Workplace Solutions UNITS – business-wise, organizational, technical technical (SYSTEMS) business-wise (SUBDOMAINS) organizational (TEAMS) 03.09.2020 //// Seite 11 WPS – Workplace Solutions UNITS - EXAMPLE: technical CORE MASTER BI This is an (over-simplified) real-world example taken from a customer‘s project!
WPS – Workplace Solutions UNITS - EXAMPLE: business-wise vs. technical CORE MASTER BI SHIPPING ARTICLES 03.09.2020 //// Seite 13 WPS – Workplace Solutions UNITS – EXAMPLE: business-wise vs. technical vs. organizational CORE MASTER BI SHIPPING ARTICLES TEAM STOCK TEAM BI TEAM SALES
WPS – Workplace Solutions CORE MASTER BI SHIPPING ARTICLES TEAM STOCK TEAM BI TEAM SALES UNITS – EXAMPLE: business-wise vs. technical vs. organizational Fractions within units cause pain! • business pain • technical pain • organizational pain And it‘s complicated, too! BIG BALL OF PAIN 03.09.2020 //// Seite 15 WPS – Workplace Solutions UNITS – THE DDD WAY: business-wise ARTICLES SHIPPING
WPS – Workplace Solutions UNITS – THE DDD WAY: business-wise vs. technical SHIPPING ARTICLES 03.09.2020 //// Seite 17 WPS – Workplace Solutions UNITS – THE DDD WAY: business-wise vs. technical vs. organizational TEAM SHIPPING TEAM ARTICLES Units are actual units – with no fractions inside! • business-wise • technically • organizationally And it‘s so simple! Almost trivial.
WPS – Workplace Solutions UNITS – ALTERNATIVES: business-wise vs. technical vs. organizational CORE MASTER BI SHIPPING ARTICLES TEAM STOCK TEAM BI TEAM SALES NOTE: The same complexity in units on both sides! To be true: there is one technical unit (i. e. system) more on the right side ;) TEAM SHIPPING TEAM ARTICLES 03.09.2020 //// Seite 19 WPS – Workplace Solutions EACH BOUNDED CONTEXT CAN HAVE ITS OWN TEAM ▪ Teams develop independently. ▪ Each team is a single point of responsibility. ▪ Each team is stellar both domain- and technology-wise.
WPS – Workplace Solutions TEAM ASSIGNMENT – EXAMPLE 2 – UI as a BOUNDED CONTEXT? UI APPLICATION INFRASTRUCTURE DATABASE TEAM ARTICLES TEAM SALES TEAM SHIPPING TEAM BILLING TEAM WEBSHOP ? VERTICAL: business layers HORIZONTAL: technical layers ARTICLES SALES BILLING SHIPPING 03.09.2020 //// Seite 23 WPS – Workplace Solutions TEAM ASSIGNMENT – EXAMPLE 3 UI APPLICATION INFRASTRUCTURE DATABASE TEAM ARTICLES TEAM SHOP TEAM SHIPPING TEAM WEBSHOP ? ARTICLES SALES BILLING SHIPPING VERTICAL: business layers HORIZONTAL: technical layers
WPS – Workplace Solutions CORE DOMAIN ▪ Part of the business domain. ▪ Of crucial importance for the company's success. ➔ This is where the company has to stand out. ➔ This project should be given the highest priority. The software system that represents the core domain is a competitive advantage! It’s not a necessary evil. ➔ Unique Selling Point (USP) Foto: Pixeleye/pixabay/CC0 03.09.2020 //// Seite 27 WPS – Workplace Solutions SUPPORTING UND GENERIC SUBDOMAIN ▪ Supporting subdomain ▪ Models an aspect that can be critical but not part of the core. ▪ Usually specific for the business. ▪ Generic subdomain ▪ Not customer- or (sometimes) industry-specific. ▪ Required for the overall solution. ➔ Not unimportant! ➔ But also no need to be excellent here. Foto:Customer support/Sharique.m3em/Wikipedia/CC-BY-SA-4.0
WPS – Workplace Solutions PARETO PRINCIPLE („80/20 RULE“) How acceptable is this in core / supporting / generic domains? 03.09.2020 //// Seite 31 WPS – Workplace Solutions BROWNFIELD STRATEGIC DESIGN ▪ Starting point: A confused monolithic Big Ball of Mud. ▪ Very likely: several mixed togeher domain models. ▪ Method: ▪ Identify the subdomains and unravel those mixed together domain models. ▪ Put up some meaningful boundaries! ➔ That‘s how we can handle complexity! ▪ Specific ubiquitous languages: ▪ Each Subdomain has its own specific ubiquitous language. ➔ Map to the legacy system‘s language in order to integrate old and new world. Foto: cpmacdonald/pixabay/CCO
WPS – Workplace Solutions HOW TO SPLIT THE MONOLITH 1. How should it be? 1. Collaborative Modeling 2. “ideal” context map 2. How is it? 1. Architecture Analysis 2. “Actual” context map 3. How to move the “actual” to the “ideal”? 1. Extract a supporting domain to learn 2. Then extract core(s) DEPTHS SOUNDING 03.09.2020 //// Seite 34 WPS – Workplace Solutions <<Aggregate>> DepthMap place(silhouette) send() <<Aggregate>> DepthMap place(silhouette) send() <<Aggregate>> DepthMap place(silhouette) send()
WPS – Workplace Solutions @JoernKoch Breadslicingmachine Bounded Context Architecture Team A Team B Dishwashingmachine SOA Bounded Context Architecture 0:1 ?
WPS – Workplace Solutions @JoernKoch Bounded Context Architecture SOA SOA SOA 03.09.2020 //// Seite 50 WPS – Workplace Solutions TECHNICAL DOMAINS ▪ WHICH TEAM TAKES CARE OF ▪ OPERATING? ▪ MESSAGING infrastructure? ▪ development of a fancy UI WIDGET LIBRARY? ▪ … ▪ In addition to the DOMAIN problem areas, there are always TECHNICAL problem areas. ▪ APPROACHES: ▪ Each team takes care of all technical aspects themselves. ▪ Possibly supplemented by "Communities of Practice" or "Tribes“. ▪ Additional teams for "technical domains“.
CONTEXT MAP ▪ Each team is aware of its context boundaries. But what is the overall picture? ▪ A context map shows ▪ all different bounded contexts ▪ and their mutual relationship. ▪ Bounded contexts should be named. 03.09.2020 //// Seite 4 WPS – Workplace Solutions CONTEXT MAP @ HAMBURG PORT TIDE FORECAST DEPTHS SOUNDING
CONTEXT MAPPING ▪ Team collaboration ▪ Partnership ▪ Separate Ways ▪ Upstream / Downstream ▪ Customer / Supplier ▪ Conformist ▪ Technical integration ▪ Private Interface ▪ Open Host Service ▪ Shared Kernel ▪ Domain modeling ▪ Published Language ▪ Anticorruption Layer 03.09.2020 //// Seite 6 WPS – Workplace Solutions PARTNERSHIP ▪ The teams agree on the interface together ▪ Common goal / interdependent goals ▪ Teams can only be successful together ▪ Regular meetings ▪ Continuous integration ▪ Generally high synchronization effort → Is it an antipattern? Foto: Wikipedia/flickr/CC-BY Ryan C
UPSTREAM / DOWNSTREAM ▪ One team creates facts for another. ▪ Upstream team implements a model. ▪ Downstream team builds on it. ▪ Data flow vs. model specification →Data flow is usually trivial →More interesting: Which team specifies the common model that is used for inter-context communication? Foto: benralexander/pixabay/CC0 03.09.2020 //// Seite 8 WPS – Workplace Solutions CONTEXT MAPPING @ HAMBURG PORT TIDE FORECAST DEPTHS SOUNDING
CUSTOMER / SUPPLIER ▪ Supplier team provides data and/or services. ▪ Customer team uses the provided data and/or services. ▪ The supplier team can be influenced by the customer team (“Customer is King!”) ▪ Customer passes requirements on to supplier. Supplier handles requirements with the same priority as the customer handles his own requirements. → Is it an antipattern? Foto: Clker-Free-Vector-Images/pixabay/CC0 03.09.2020 //// Seite 10 WPS – Workplace Solutions CONTEXT MAPPING @ HAMBURG PORT TIDE FORECAST DEPTHS SOUNDING
CONFORMIST ▪ The upstream team does not implement any requirements of the downstream team. ▪ The downstream team adopts the model of the upstream team 1:1. Foto: Staff Sgt. D. Myles Cullen/Wikipedia/PD US Air Force 03.09.2020 //// Seite 12 WPS – Workplace Solutions CONTEXT MAPPING @ HAMBURG PORT TIDE FORECAST DEPTHS SOUNDING
ANTICORRUPTION LAYER ▪ The anti-corruption layer… ▪ is an architecture layer that mediates between the domain model and the model of an adjacent system. ▪ protects your own domain model from being unintentionally influenced by the model of the adjacent system. Domain Model Anticorruption Layer Adjacent System 03.09.2020 //// Seite 14 WPS – Workplace Solutions CONTEXT MAPPING @ HAMBURG PORT TIDE FORECAST DEPTHS SOUNDING
SEPARATE WAYS ▪ If integrating two bounded contexts makes no sense, let each team go their own way. ▪ Each team with their own specific solution. Foto: Doris Antony/Wikipedia/CC-BY-SA-4.0,3.0,2.5,2.0,1.0 03.09.2020 //// Seite 16 WPS – Workplace Solutions BIG BALL OF MUD ▪ THE context mapping antipattern. Foto: Benutzer:Summi/Wikipedia/CC-BY-SA-3.0-migrated
PRIVATE INTERFACE ▪ Defines a protocol / interface between 2 bounded contexts (Not in the "blue book".) ▪ Not open to others. ▪ Increases the mutual dependency of two contexts. ▪ Often not that well documented. Foto: 3D Tin Can Phones/flickr/C-BY Chris Potter 03.09.2020 //// Seite 18 WPS – Workplace Solutions OPEN HOST SERVICE ▪ Defines a protocol / interface of a bounded context as a set of services. ▪ Open == anyone can use the protocol. ▪ The resulting API is well defined and documented. ▪ Simplified model (least common denominator). Foto: edwardpye/pixabay/CC0
CONTEXT MAPPING @ HAMBURG PORT TIDE FORECAST DEPTHS SOUNDING 03.09.2020 //// Seite 20 WPS – Workplace Solutions PUBLISHED LANGUAGE ▪ A well-documented language for exchanging information. ▪ Can be defined in ▪ XML schema ▪ JSON scheme ▪ Protobuf ▪ etc. ▪ An open host service often "speaks" a PL. ▪ Examples: ▪ SEPA-XML for transfers and mandates ▪ BIPRO for insurance ▪ HL7 for healthcare ▪ WMS for map data Foto: Merker Berlin/Wikipedia/PD-self
CONTEXT MAPPING @ HAMBURG PORT CARTO- GRAPHY 03.09.2020 //// Seite 22 WPS – Workplace Solutions SHARED KERNEL ▪ Teams sometimes use similar models. ▪ In order to avoid duplication, these teams agree on a shared sub-model, the shared kernel. ▪ If this shared kernel is further developed, all teams involved will be included. ▪ The contexts of the teams remain separated from each other. Foto: Sander van der Wel/Wikipedia/CC BY-SA 2.0
CONTEXT MAPPING @ HAMBURG PORT TIDE FORECAST DEPTHS SOUNDING CARTO- GRAPHY CORE GEN. GEN. SUPP. 03.09.2020 //// Seite 26 WPS – Workplace Solutions OVERVIEW Required Communication Separate Ways Conformist Anti Corruption Layer Customer Supplier Open Host Service Shared Kernel Single Bounded Context
Science: cache invalidation and naming things.” Phil Karlton 03.09.2020 //// Seite 4 WPS – Workplace Solutions TECHNO BABBLE Can I push to feature branch? Please deploy the container I create an interface for that Foto: Boboss74/deviantart Foto: Cronoxyd/Wikipedia/CC BY-SA 3.0 Foto: Microsoft/Wikipedia/PD ineligible
DOMAIN LANGUAGE – CHESS II draw zugzwang checkmate game move castling 03.09.2020 //// Seite 8 WPS – Workplace Solutions DOMAIN LANGUAGE – CHESS III to resign to draw to capture to hit the chess clock to castle
FINDING THE RIGHT TERMS A B C D E F G • Categorize • Which criteria did you use? 03.09.2020 //// Seite 10 WPS – Workplace Solutions WHY DO WE NEED A UBIQUITOUS LANGUAGE? Domain Lingo Techno Babble ? Domain Expert Developer
Fach- sprache Techno Babble Domain Lingo WHY DO WE NEED A UBIQUITOUS LANGUAGE? 03.09.2020 //// Seite 12 WPS – Workplace Solutions Domain Lingo Techno Babble WHY DO WE NEED A UBIQUITOUS LANGUAGE?
Techno Babble Domain Lingo WHY DO WE NEED A UBIQUITOUS LANGUAGE? 03.09.2020 //// Seite 14 WPS – Workplace Solutions Domain Lingo Techno Babble UBIQUITOUS LANGUAGE
UBIQUITOUS LANGUAGE ▪ Domain experts do not understand terms relating to technical implementation. ▪ Domain experts speak the jargon of their domain, which in turn can be difficult for outsiders to understand. ➔ A common language is necessary! ▪ Which should it be? ▪ The developer’s? ▪ The domain expert’s? ▪ Something in between? ➔ Principle of DDD: "Use a language based on the domain model" Foto: The Tower of Babel/Pieter Brueghel the Elder/Wikipedia/CC-PD-Mark 03.09.2020 //// Seite 18 WPS – Workplace Solutions UBIQUITOUS LANGUAGE ▪ Use the ubiquitous language in .. ▪ communication ▪ orally ▪ written ▪ graphically ▪ code ▪ Basically everywhere ➔ That is why the language is called ubiquitous.
Fach- sprache Techno Babble Domain Lingo HOW DO WE DEVELOP A UBIQUITOUS LANGUAGE? 03.09.2020 //// Seite 20 WPS – Workplace Solutions HOW DO WE DEVELOP A UBIQUITOUS LANGUAGE? ▪ Event Storming ▪ Domain Storytelling ▪ Interviews ▪ Plain text scenarios ▪ Glossaries
SINGLE SENTENCE RULE… »The sounding service sends the completed depth map to the navigator.« SOUNDING SERVICE NAVIGATOR SENDS COMPLETED DEPTH MAP TO 03.09.2020 //// Seite 26 WPS – Workplace Solutions Actor Work Object Activity Note IMAGE TABLET
Person Group IT System IMAGE TABLET - ACTORS 03.09.2020 //// Seite 28 WPS – Workplace Solutions IMAGE TABLET - WORK OBJECTS SOUNDS COMPILES DEPTH MAP DEPTH
IMAGE TABLET - MEDIA ROUTE COMPLETED DEPTH MAP REQUESTS SENDS 03.09.2020 //// Seite 30 WPS – Workplace Solutions Actor Work Object Activity Note IMAGE TABLET - NO IF / SWITCH / OR / …
ACTORS: UNIQUE / WORK OBJECTS: MULTIPLE 4 3 DEPTH MAP COMPLETED DEPTH MAP SOUNDING SERVICE Draw here Leave some empty space there → Annotations, variations, and purpose Preconditions, assumptions, and triggers Name of the Domain Story
"Because sometimes three good examples are better for understanding the requirements than a bad abstraction. “ Peter Hruschka in Busines Analysis und Requirements Engineering, S.102, Hanser, 2014 03.09.2020 //// Seite 34 WPS – Workplace Solutions COLLABORATIVE VS MODERATED
including everything you need to know Short Overview 15$ online: leanpub.com/domainstorytelling Free (but in German) Introduction including everything you need to know Short Overview
We recommend: ▪ Talk, talk, talk ▪ Collaborative Modeling: ▪ Event storming ▪ Domain storytelling ▪ Interviews & scenarios ▪ Glossaries ... DEVELOPING THE UBIQUITOUS LANGUAGE Fach- sprache Domain Lingo 03.09.2020 //// Seite 43 WPS – Workplace Solutions UML, BPMN & Co should be treated with caution: ▪ By software developers for software developers ▪ Conditionally suitable for workshops → risk of imposing an unwanted IT view on the customer ▪ Focus on documentation rather than communication DIE UBIQUITOUS LANGUAGE ENTWICKELN Domain Lingo Techno Babble ?
GLOSSARY ▪ For core concepts (because a lot of work) ▪ existing terms ▪ reconstructed terms ▪ new terms ▪ More important at the beginning of the project and for new employees. ▪ Often a disposable product (no longer maintained). ▪ A dictionary does not replace a language course! Foto: George Eastman Museum/Wikipedia 03.09.2020 //// Seite 46 WPS – Workplace Solutions ▪ A team speaks its own language → Family language, dialect ▪ The same terms can have (slightly) different meanings. ▪ Language and model are closely linked. EVERY BOUNDED CONTEXT HAS ITS OWN UBIQUITOUS LANGUAGE MARKING DEPTHS MAP DEPTH DEPTHS SOUNDING SOUNDING SHIP DEPTH
EVERY BOUNDED CONTEXT HAS ITS OWN GLOSSARY DEPTH MEASURED BY ECHO SOUNDER BELOW SEA LEVEL DEPTHS SOUNDING DEPTH DEPTH AT A SPECIFIC GEO POSITION DEPENDING ON EBB AND FLOW TIDE MANEUVER PLANNING MEASURED DEPTH Integer value in centimeters based on sea level You may also want to introduce a „traditional“ data dictionary as a „glossary“ of the published language 03.09.2020 //// Seite 48 WPS – Workplace Solutions LANGUAGE DOES NOT JUST APPEAR ▪ It takes weeks to months ... ▪ of hard work ▪ and sharp focus ▪ ... to reveal the key concepts. ▪ The first words of a ubiquitous language usually come straight from the domain. ▪ During development, new terms will be defined and added.
UBIQUITOUS LANGUAGE – ITERATION 2 pieces player computer player board Foto: Fotograf Frank Hoppe/ Garry Kasparov/Wikipedia/PD-self Foto: Wikipedia/PD shape Foto: Wikipedia/CC BY-SA 3.0 Foto: Jim Gardner/Wikipedia/CC BY 2.0 03.09.2020 //// Seite 52 WPS – Workplace Solutions LANGUAGES ARE ALIVE ▪ Experiment with alternative expressions. ▪ The model and language continue to evolve. ▪ Then refactor the code ▪ Name classes, methods, modules ▪ Correspond to the new model ▪ A language wants to be spoken: ▪ Eliminate ambiguity through continuous communication. Foto: Tkgd2007/Wikipedia/CC BY-SA 3.0
DISCUSS AND SOLVE PROBLEMS USING DOMAIN LANGUAGE When developers face technical problems ... ... the developers can try to solve those on their own, considering them as mere technical issues, ... or they MAY find a simple and appropriate workaround with the help of the domain experts. To achieve this, we need to describe the technical problem from a domain perspective using the ubiquitous language. Bild: pinterest.com 03.09.2020 //// Seite 54 WPS – Workplace Solutions EXAMPLE: SOLVING TECHNICAL PROBLEMS USING DOMAIN LANGUAGE Developers among themselves: "How do we build housekeeping of the ship silhouette table in the Oracle DB?" "No idea, let's ask the navigator." Developer to Navigator: "How long do we have to keep those silhouettes of the ships?“ Navigator: “You don’t have to any more. It used to be helpful when we still had to tinker those out of cardboard. Now with the software it's so easy to just create a new silhouette. It’s okay that way. “ Developer at his computer: "DROP TABLE ship silhouettes;"
PRACTICE: EXTRACT UBIQUITOUS LANGUAGES ▪ Write a glossary for a term that is used in at least 2 subdomains. ▪ One card / stickie per term / subdomain ▪ brief definition / description (1 – 2 sentences) Foto: Derks24/pixabay/CC0
Workplace Solutions DOMAIN-DRIVEN DESIGN – LAYER ARCHITECTURE ▪ User interface layer ▪ Receives input and user commands and presents information. ▪ Application layer (Fowler: Service Layer) ▪ Describes and coordinates application processes. ▪ Domain layer ▪ Represents the business domain logic. ▪ Infrastructure layer ▪ Provides technical services such as persistence or communication with other systems. User Interface Domain Infrastructure Application 03.09.2020 //// Seite 6 WPS – Workplace Solutions ARCHITECTURE OF DOMAIN LAYER? User Interface Domain Infrastructure Application MANEUVER- PLANNING
Workplace Solutions FOWLER: DOMAIN LOGIC PATTERNS ▪ Transaction Script ▪ Table Module ▪ Domain Model ▪ (Anemic Domain Model) ▪ (Polluted Domain Model) Foto: Autor Webysther Nunes/Martin Fowler/Wikipedia/CC-BY-SA-4.0 03.09.2020 //// Seite 8 WPS – Workplace Solutions TRANSACTION SCRIPT ▪ Organizes the business logic into individual procedures. ▪ Each procedure covers a request from the presentation layer. ▪ Transaction brackets correspond directly to procedures. ▪ Communication directly or only via a slim adapter with database. ▪ Suitable for simple problems. calculateZoomLevel( depthMapId: long, zoom: byte ): byte[][] Button UI- + domain logic persistent domain data
Workplace Solutions TABLE MODULE ▪ Business logic implemented in one class per database table. ▪ Algorithms work directly on result sets! Depth Maps calculateZoomLevel( depthMapId, zoom ): byte[][] getDepthMap( depthMapId ) : ResultSet domain logic persistent domain data 03.09.2020 //// Seite 10 WPS – Workplace Solutions DOMAIN MODEL ▪ Typical way of object-oriented modeling. ▪ POJOs / POCOs / POPOs ▪ Design independent of database. ▪ OR mapping is necessary. ▪ Use of concepts such as encapsulation, locality and delegation. DepthMap calculateZoomLevel( scale: Scale ): ZoomLevel ZoomLevel persistency Scale domain logic + data
Workplace Solutions ▪ Entities named as per domain ▪ domain-specific behavior is missing ▪ getters and setters only ➔ Java beans ▪ "Crippled" entities (just data structures) ▪ Domain logic pulled up to service layer. ANEMIC DOMAIN MODEL Foto: Vampire/Wikipedia/FAL DepthMapService calculateZoomLevel( DepthMap ) DepthMap getDepths() setDepths() 03.09.2020 //// Seite 12 WPS – Workplace Solutions ▪ Domain Model ▪ Polluted by technology-specific code ▪ e. g. JPA annotations POLLUTED DOMAIN MODEL
Workplace Solutions DOMAIN LOGIC + DATA: »WHAT BELONGS TOGETHER GROWS TOGETHER« FRONTEND BACKEND DB Transaction Script Table Module Domain Model FRONTEND BACKEND DB FRONTEND BACKEND DB domain logic + data Persistency UI- + domain logic persistent domain data persistent domain data domain logic UI logic UI Logic UI- + domain logic UI- + domain logic “So that you can live in peace tomorrow” 03.09.2020 //// Seite 14 WPS – Workplace Solutions MARTIN FOWLER ON DDD “Eric Evans is currently writing a book on building Domain Models. As I write this I’ve seen only an early manuscript, but it looks very promising.” Foto: Autor Webysther Nunes/Martin Fowler/Wikipedia/CC-BY-SA-4.0
Workplace Solutions FOWLER: WANN MODELLIERT MAN EINE FACHDOMÄNE? Development effort Complexity of domain logic Table Module Transaction Skript Anemic DM Polluted DM 03.09.2020 //// Seite 16 WPS – Workplace Solutions EACH BOUNDED CONTEXT HAS ITS INDIVIDUAL ARCHITECTURE MANEUVER- PLANNING DEPTHS SOUNDING Transaction Script Domain Model
Workplace Solutions LAYER ARCHITECTURE – CRITIQUE User Interface Domain Infrastructure Application MANEUVER- PLANNING ▪ Domain layer is linked to the database layer ▪ Technology “bubbles up” into domain layer ▪ No clean separation of domain & technology Alistair Cockburn Foto: Fotograf Dennis Hamilton/Alistair Cockburn/flickr/CC BY 2.0 03.09.2020 //// Seite 18 WPS – Workplace Solutions FROM LAYERS TOWARDS HEXAGONS ▪ The UI layer and the infrastructure layer are both things that make the domain logic available to the outside world. ▪ The hexagonal architecture therefore placed UI and infrastructure on the same “layer” ▪ Outside vs inside instead of above vs below ▪ A hexagon offers ports (the edges) ▪ Adapters are placed upon the ports http://alistair.cockburn.us/Hexagonal+architecture DOMAIN Port Port Adapter Adapter
Workplace Solutions CLEAN ARCHITECTURE Robert C. Martin ”Uncle Bob“ 03.09.2020 //// Seite 20 WPS – Workplace Solutions Dependency Inversion Principle (DiP) a. „High-level modules should not depend on low-level modules. Both should depend on abstractions (e.g. interfaces). b. Abstractions should not depend on details. Details (concrete implementations) should depend on abstractions.“ Robert C. Martin ”Uncle Bob“
Workplace Solutions THE DOMAIN KERNEL ▪ DDD IDEA: SEPARATE TECHNICAL AND DOMAIN ARCHITECTURE! ▪ This can be better expressed by hexagons: The domain kernel is the very core! ▪ The domain kernel can be viewed as a technology-independent “domain framework” that provides a complete implementation of the domain logic. Domain logic + terms Port Port Adapter Adapter DOMAIN KERNEL 03.09.2020 //// Seite 22 WPS – Workplace Solutions BOUNDED CONTEXT THE DOMAIN KERNEL WITHIN A BOUNDED CONTEXT Domain logic + terms Port Port Adapter Adapter DB UI
Workplace Solutions THE DOMAIN KERNEL – THE CELL NUCLEUS CONTAINING THE „DOMAIN DNA“ Bild: https://philschatz.com/anatomy-book/resources/0312_Animal_Cell_and_Components.jpg
Workplace Solutions THE BASIC IDEA OF OBJEKT ORIENTATION: A SOFTWARE-TECHNICAL MODEL BASED ON DOMAIN OBJECTS 03.09.2020 //// Seite 26 WPS – Workplace Solutions FROM SCENARIO TO DOMAIN MODEL A scenario shows us how we do work with domain objects
Workplace Solutions BACK TO THE SCENARIO DEPTH ft« SOUNDED DEPTH COLORED »RED« 03.09.2020 //// Seite 28 WPS – Workplace Solutions DEPTH ft« SOUNDED DEPTH COLORED »RED« LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS
Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS 03.09.2020 //// Seite 30 WPS – Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS WHO does WHAT using WHICH THINGS, in order to get from the start event to the end event? … …
Workplace Solutions EXCURSUS: ZOOMING IN / OUT IN DEPTH MAPS 03.09.2020 //// Seite 32 WPS – Workplace Solutions ZOOMING OUT REDUCES THE RESOLUTION OF DEPTHS
Workplace Solutions Shallowest depth in this area: 11.2 m WE HAVE TO REPLACE ALL DEPTHS BY THE SHALLOWEST DEPTH (BECAUSE THE SHIP COULD RUN AGROUND THERE) 03.09.2020 //// Seite 34 WPS – Workplace Solutions 11.2 Shallowest depth in this area: 11.2 m IN ORDER TO CALCULATE A ZOOM LEVEL, WE REPEAT THIS FOR ALL AREAS OF THE DEPTH MAP
Workplace Solutions AND GET A LOWER RESOLUTION PLAN, SO, WHEN ZOOMING OUT WE CAN STILL SEE ALL RELEVANT DEPTHS 03.09.2020 //// Seite 36 WPS – Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS
Workplace Solutions COMMAND An ACTION TO BE TAKEN in order to reach the next event. 03.09.2020 //// Seite 38 WPS – Workplace Solutions SET THE SCALE FOR THE ZOOM LEVEL BLUE STICKIE In IMPERATIVE COMMAND
Workplace Solutions timeline LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS 03.09.2020 //// Seite 40 WPS – Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS
Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS 03.09.2020 //// Seite 42 WPS – Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS
Workplace Solutions ACTORS OF A SCENARIO ACTOR 03.09.2020 //// Seite 44 WPS – Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS
Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS 03.09.2020 //// Seite 46 WPS – Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS
Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS ZOOM LEVEL YELLOW STICKIE NOUN Domain Term 03.09.2020 //// Seite 48 WPS – Workplace Solutions LET'S BUILD SOFTWARE FOR ZOOMING IN / OUT IN DEPTH MAPS
Workplace Solutions SO, WHAT‘S NEXT? 03.09.2020 //// Seite 52 WPS – Workplace Solutions THE BASIC IDEA OF OBJEKT ORIENTATION: A SOFTWARE- TECHNICAL MODEL BASED ON DOMAIN OBJECTS
Workplace Solutions LENGTH ... are modeled by their behavior ... ... and implemented in domain classes. Length Position public class Silhouette { void moveBy(Length len) { assert len != null; … position.add(len)); } } Domain objects… MOVES LENGTH SILHOUETTE SILHOUETTE MOVED MOVE BY SILHOUETTE NAVIGATOR 03.09.2020 //// Seite 54 WPS – Workplace Solutions LENGTH FROM EVENT STORMING TO DOMAIN MODEL Silhouette SILHOUETTE SILHOUETTE MOVED MOVE BY LENGTH moveBy(:Length) Length
Workplace Solutions FROM DOMAIN STORY TO DOMAIN MODEL Silhouette MOVES SILHOUETTE NAVIGATOR LENGTH Length moveBy(:Length) BY 03.09.2020 //// Seite 61 WPS – Workplace Solutions Label - add keyword - compare with other label Keyword Tab - tag - insert document by date tag document date (Responsibility) - remove document - insert document - label - find document by keyword - create tabs (Collaborator) Document Label Date Tab Folder (Class) CRC cards
Workplace Solutions (Responsibility) - remove document - insert document - label - find document by keyword - create tabs (Collaborator) Document Label Date Tab Folder (Class) ENTITY COMMAND COLLABO -RATOR BASIC IDEA: Reuse DOMAIN TERM and COMMAND stickies from event storming!!! 03.09.2020 //// Seite 65 WPS – Workplace Solutions STICKIES INSTEAD OF CRC CARDS – STEP 1 DOCUMENT LABEL DATE TAB FOLDER label find document by keyword create tab tag add document by date KEYWORD get keyword compare with other label insert document remove document • Take domain terms (yellow) and commands (blue) from event storming. • Assign a command to a domain term, if the command modifies or inspects the designated artifact.
Workplace Solutions STICKIES INSTEAD OF CRC CARDS – STEP 2 • Add collaborators (use pink or any other color). DOCUMENT LABEL DATE TAB FOLDER label find document by keyword create tab tag add document by date KEYWORD get keyword compare with other label insert document remove document DOCUMENT LABEL DATE TAB KEYWORD LABEL DOCUMENT 03.09.2020 //// Seite 67 WPS – Workplace Solutions DOCUMENT LABEL DATE TAB FOLDER label find document by keyword create tab tag add document by date KEYWORD get keyword compare with other label insert document remove document STICKIES INSTEAD OF CRC CARDS – STEP 3 – DONE! • Replace collaborators by arrows. → RESULT: An object-oriented class diagram!
Workplace Solutions ... AND THIS IS HOW THE SAME MODEL WOULD LOOK AS A CLASS DIAGRAM: Folder ▪ createTab: Tab ▪ findByLabel(Label): Document ▪ label(Label) ▪ insert(Document) ▪ remove(Document) Label ▪ compareTo(Label) ▪ getKeyword: Keyword Keyword Tab ▪ addByDate(Document, Date) ▪ tag(Tag) Date Document 03.09.2020 //// Seite 69 WPS – Workplace Solutions ... AND THIS IS HOW THE SAME MODEL WOULD LOOK AS A CLASS DIAGRAM: Folder ▪ createTab: Tab ▪ findByLabel(Label): Document ▪ label(Label) ▪ insert(Document) ▪ remove(Document) Label ▪ compareTo(Label) ▪ getKeyword: Keyword Keyword Tab ▪ addByDate(Document, Date) ▪ tag(Tag) Date Document
AND CREATE A DOMAIN MODEL 03.09.2020 //// Seite 72 WPS – Workplace Solutions WE CODE RIGHT AWAY – STARTING POINT: EVENT STORMING SAALPLAN GEHOLT VORSCHLAG ANGE- NOMMEN PREIS BAR BEZAHLT
Workplace Solutions WE CODE RIGHT AWAY – FROM PSEUDO CODE TO DOMAIN MODEL SAALPLAN GEHOLT VORSCHLAG ANGE- NOMMEN PREIS BAR BEZAHLT 03.09.2020 //// Seite 76 WPS – Workplace Solutions WE CODE RIGHT AWAY – TEST-DRIVEN: MAKE IT RUN SAALPLAN GEHOLT VORSCHLAG ANGE- NOMMEN PREIS BAR BEZAHLT
Workplace Solutions WE CODE RIGHT AWAY – RESULT ▪We can create a complex and elaborate domain model based on just a single scenario. ▪By testing, we can make sure that this domain model fits the scenario completely and perfectly! ▪Any additional scenario gradually leads to an improved and more comprehensive domain model! ▪The more precise the scenarios, the better and more elaborate our domain model. SAALPLAN GEHOLT VORSCHLAG ANGE- NOMMEN PREIS BAR BEZAHLT 03.09.2020 //// Seite 78 WPS – Workplace Solutions TYPES OF OPERATIONS IN OBJECT ORIENTED INTERFACES Operations describe the way in which objects are worked with in various scenarios. We differentiate: ▪ What information is "read" from the objects? ▪ What changes are made to the objects and what actions are triggered (except destructive actions or actions transforming the object into another type of object)? →CQS principle of Bertrand Meyer Ship‘s Silhouette • move by • twist • position? • overall length? • width? ...
Workplace Solutions ▪ An operation should either ▪ modify the object‘s state ➔ Command ▪ read the object‘s state ➔ Query ▪ But never both! COMMAND QUERY SEPARATION 03.09.2020 //// Seite 80 WPS – Workplace Solutions ▪Reading the object‘s state should never have any side effects! ▪Anything else would be a risky game. COMMAND QUERY SEPARATION Foto: Urheber Fuchsias/Bertrand Meyer/Wikipedia/CC BY-SA 4.0
Workplace Solutions INTERFACES OF DOMAIN CLASSES The concept of modeling domain classes: ▪ Choose domain-specific terms (→ nouns) ▪ Describe their operations (→ verbs) and additional domain objects required. DO NOT JUST MODEL DATA! Ship‘s Silhouette • move by • twist • position? • overall length? • width? ... 03.09.2020 //// Seite 82 WPS – Workplace Solutions UBIQUITOUS LANGUAGE AND DOMAIN MODEL DepthsMap calculateZoomLevel Marking Depth ZoomLevel MARKING DEPTHS MAP DEPTH ZOOM- LEVEL WE ARE IN THE MIDDLE OF AN AGILE PROCESS OF LANGUAGE AND MODEL DEVELOPMENT
Entities Value Objects Aggregates Services Factories Repositories 03.09.2020 //// Seite 4 WPS – Workplace Solutions DOMAIN TERMS – WHAT IS STRIKING? insurance policy vacation request building activity purchase contract order zip code GPS coordinate IBAN container number IATA code
ENTITIES ▪ Objects of a domain that the user works with. ▪ The results of the work are reflected by their state! ▪ Can be composed of other entities. ▪ Have an (immutable) identity. ▪ Maintain their own consistency and integrity! ▪ Have a clearly defined life cycle. ▪ Have a (mostly mutable) state. ▪ Describe their state by value objects. ▪ Synonyms: Business Object / Domain Object / Work Material ▪ NOT TO BE confused with the term "ENTITY" from Entity- Relationship-Model! Foto: Bundesrepublik Deutschland/Wikipedia/PD Germany Foto: Kaz/pixabay/CC0 Foto: Thomas G./Wikipedia/CC BY-SA 3.0 Foto: OpenClipart-Vectors/pixabay/CC0
ENTITIES <<Entity>> DepthMap depthMapId mark(Marking) 03.09.2020 //// Seite 8 WPS – Workplace Solutions VALUE OBJECTS ▪ Value objects are symbols for values of a certain type in the domain. ▪ Symbolize the same value if they are equal. ▪ They are not edited by the user and cannot be modified. ▪ Can be calculated (from other value objects), if necessary. ▪ Can consist of other value objects, but never of entities! ValueObject 2,5 ValueObject ValueObject ValueObject ValueObject zwei- einhalb
VALUE OBJECTS - MORE ▪ Whole Value ▪ Methods may not change the state, but may return "new" value objects ▪ A lot of boilerplate code is required in Java → Project Lombok ▪ Operator overloading ▪ The same term can designate an entity in one bounded context and a value object in the other. 03.09.2020 //// Seite 12 WPS – Workplace Solutions PRACTICE: IDENTIFY THE BUILDING BLOCK TYPES – PART 1 ▪ Review your domain model: ▪ What is an entity? What is a value object? ▪ What else do we need?
AGGREGATES ▪ Aggregates are entities that are relevant in themselves (and not just as part of another entity). ▪ Protect the consistency and integrity of their inner entities. ▪ They don't necessarily have to hide them to do this! ▪ Always have a designated entity as an entry point (root). ▪ Usually stored. ▪ As a whole! ▪ Not necessarily in a relational way! Root Entity VO VO VO Aggregate 03.09.2020 //// Seite 14 WPS – Workplace Solutions AGGREGATES ▪ Actually, the value objects are outside as they are immutable and may be reused anywhere. Root Entity VO VO VO Some other object Aggregate
Aggregate <<Aggregate Root>> DepthMap <<Entity>> Marking <<Value Object>> Depth 03.09.2020 //// Seite 18 WPS – Workplace Solutions REPOSITORIES ▪ Are the access points to the aggregates! ▪ Encapsulate the technical details of the technical infrastructure layer ... ▪ ... and map external data to entities and value objects. ▪ Store aggregates (e. g. in databases). Repository
PRACTICE: IDENTIFY THE BUILDING BLOCK TYPES – PART 2 ▪ Which entities are in fact aggregates? ▪ Which repositories do we need? 03.09.2020 //// Seite 22 WPS – Workplace Solutions Service (DOMAIN) SERVICES ▪ (Domain) services represent fixed procedures or processes of the domain. ▪ Unless those can be executed by aggregates / entities. ▪ Are stateless! ▪ Parameters and results of their operationens are aggregates and value objects.
ZoomService 03.09.2020 //// Seite 24 WPS – Workplace Solutions FACTORIES ▪ Factories create aggregates (and sometimes value objects). ▪ However, aggregates and value objects do not have to be created by factories. ▪ new DepthMap() is ok! Factory
▪ Orchestrate use cases. ▪ Provide technical access to the domain layer. ▪ Leverage domain logic from the domain layer, but DO NOT implement any domain logic themselves! ▪ Are located within the application layer (ABOVE the domain layer)! ▪ Provide an API / form a facade. ▪ Application / technology-driven ▪ Transactions ▪ Security ▪ Backend for frontend APPLICATION SERVICE Foto: Fotograf Andreas Praefcke/Wikipedia/PD-self 03.09.2020 //// Seite 26 WPS – Workplace Solutions Domain ELEMENTS OF THE DOMAIN KERNEL User Interface Infrastructure Application Domain Service Factory Aggregate Value Object Repository Root Entity Entity Entity Application Service
Domain ELEMENTS OF THE DOMAIN KERNEL User Interface Infrastructure Application Domain Service Factory Aggregate Value Object Root Entity Entity Entity Application Service Repository Interface 03.09.2020 //// Seite 28 WPS – Workplace Solutions Domain Kernel RepoInMemory Repo RepoTest • Repo: Interface of the repository → „syntax“ • RepoTest: Acceptance tests / unit test of the repository → „semantics“ • RepoInMemory: Reference implementation of the repository • Transient. • Can be used as a (comprehensively tested) “mock object” in tests. • Can rapidly be implemented during a mob-programming session. Aggregate EVEN MORE ACCURATE
THE »CORE ELEMENTS« Services Value Objects Entities stateless (mostly) mutable state immutable state »Micro layering« (not strict!) 03.09.2020 //// Seite 32 WPS – Workplace Solutions ELEMENTS OF THE DOMAIN KERNEL Services Factories Aggregates Repositories »Micro layering« (not strict!) Domain objects Support the life cycle of the domain objects Entities Value Objects
Domain event DOMAIN EVENTS ▪ Signalize events that are relevant from a domain perspective. ▪ Signalize events that have happened. ▪ NOT those that are supposed to happen! ▪ Some bounded contexts react on these technical events, others do not. ▪ Are used for communication between bounded contexts and ... ▪ ... promote their decoupling, ▪ ... facilitate asynchronous processes. ▪ Often communicated by messaging. 03.09.2020 //// Seite 34 WPS – Workplace Solutions MANEUVER -PLANNING DEPTH MAP COMPLETED DOMAIN EVENTS @ HAMBURG PORT
DOMAIN EVENTS – EXAMPLES InvoiceIssued TransferDone BookSold AccountOpened 03.09.2020 //// Seite 36 WPS – Workplace Solutions PRACTICE: IDENTIFY THE BUILDING BLOCK TYPES – PART 3 ▪ Which domain services / factories / application services do you still need? ▪ Which domain events?