Lecture 23: Domain-Driven Design (Part 1)

Similar documents
Tackling Complexity in the Heart of Software. Domain-Driven Design 카페서비스개발팀 조영호

Introduction to User Stories. CSCI 5828: Foundations of Software Engineering Lecture 05 09/09/2014

DDD Where s the value and what s in it for me?

Architecting and Implementing Domain-driven Design Patterns in.net

cs465 principles of user interface design, implementation and evaluation

CaseComplete Roadmap

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

(2 1) What does evaluate to? What does evaluate to? What does evaluate to?

Administrivia. Added 20 more so far. Software Process. Only one TA so far. CS169 Lecture 2. Start thinking about project proposal

MiPhone Phone Usage Tracking

Heuristic evaluation is a usability inspection technique developed by Jakob Nielsen. The original set of heuristics was derived empirically from an

SOFTWARE REQUIREMENTS ENGINEERING LECTURE # 7 TEAM SKILL 2: UNDERSTANDING USER AND STAKEHOLDER NEEDS REQUIREMENT ELICITATION TECHNIQUES-IV

Designing the M in MVC

Case study on PhoneGap / Apache Cordova

Understanding. Domain-Driven Design

4 KEY FACTORS FOR DATA QUALITY ON A DATA LAKE (OR: HOW TO AVOID THE DATA SWAMP) JOSH HERRITZ MIOSOFT CORPORATION MIOsoft Corporation.

Lecture 4: Design Concepts For Responsibility- Driven Design Kenneth M. Anderson January 20, 2005

Due on: May 12, Team Members: Arpan Bhattacharya. Collin Breslin. Thkeya Smith. INFO (Spring 2013): Human-Computer Interaction

6.001 Notes: Section 15.1

Agile Architecture. The Why, the What and the How

Design First ITS Instructor Tool

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

CS 160: Evaluation. Outline. Outline. Iterative Design. Preparing for a User Test. User Test

CS 160: Evaluation. Professor John Canny Spring /15/2006 1

DITA for Enterprise Business Documents Sub-committee Proposal Background Why an Enterprise Business Documents Sub committee

Proofwriting Checklist

Read & Download (PDF Kindle) Data Structures And Other Objects Using Java (4th Edition)

Chapter 1 Introduction

DDD and BDD. Dan North ThoughtWorks

INFORMATION RETRIEVAL AND THE THESAURUS R.M. Needham T. Joyce Cambridge Language Research Unit.

Data Structures And Other Objects Using Java Download Free (EPUB, PDF)

1 Achieving IND-CPA security

Who we are: Kristin Martin, Metadata Librarian, Catalog Department Peter Hepburn, Digitization Librarian, Digital Programs Department

(Refer Slide Time 6:48)

Requirements. Requirements. Types of Requirement. What Is a Requirement?

Domain Driven Design IS. An architectural methodology for evolving a software system that closely aligns to business requirements

DESIGN AS RISK MINIMIZATION

INTRODUCTION. 2. User-centred interface design.

1: Introduction to Object (1)

Credit where Credit is Due. Lecture 29: Test-Driven Development. Test-Driven Development. Goals for this lecture

Introduction to Programming

Federal Plain Language Guidelines

Topic C. Communicating the Precision of Measured Numbers

Scenarios, Storyboards, Wireframes, Critique. Jon Kolko Professor, Austin Center for Design

Systems software design

Additional reading for this lecture: Heuristic Evaluation by Jakob Nielsen. Read the first four bulleted articles, starting with How to conduct a

CSCI 403: Databases 13 - Functional Dependencies and Normalization

Heuristic Evaluation of Team Betamax

GUI Design Principles

Virtualization. Q&A with an industry leader. Virtualization is rapidly becoming a fact of life for agency executives,

CS519: Computer Networks. Lecture 2, part 2: Feb 4, 2004 IP (Internet Protocol)

Practical Object-Oriented Design in Ruby

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Lecture 10 Notes Linked Lists

(Refer Slide Time 3:31)

Object Persistence Design Guidelines

Usability Inspection Report of NCSTRL

Design Heuristics and Evaluation

monolith to micro-services? event sourcing can help Doug

PROFESSOR: Last time, we took a look at an explicit control evaluator for Lisp, and that bridged the gap between

The Specification Phase

CSE 440: Introduction to HCI User Interface Design, Prototyping, and Evaluation


Graph Theory. 26 March Graph Theory 26 March /29

(Refer Slide Time: 06:01)

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).

Object-Oriented Software Engineering Practical Software Development using UML and Java

Overview of Sentence Order Reference Document Development Process

3 Continuous Integration 3. Automated system finding bugs is better than people

4.7 Approximate Integration

What You Don t Know Will Haunt You.

Engineering Mechanics Prof. Siva Kumar Department of Civil Engineering Indian Institute of Technology, Madras Statics - 4.3

CS519: Computer Networks

CS140 Lecture 03: The Machinery of Computation: Combinational Logic

Cassandra Platform - A Case Study

Participants. Results & Recommendations. Summary of Findings from User Study Round 3. Overall. Dashboard

Foundations, Reasoning About Algorithms, and Design By Contract CMPSC 122

Kuratowski Notes , Fall 2005, Prof. Peter Shor Revised Fall 2007

Software Development Methodologies

Domain Analysis. SWEN-261 Introduction to Software Engineering. Department of Software Engineering Rochester Institute of Technology.

Extension Web Publishing 3 Lecture # 1. Chapter 6 Site Types and Architectures

Professor Hausi A. Müller PhD PEng FCAE Department of Computer Science Faculty of Engineering University of Victoria

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi.

SFU CMPT week 11

XP: Planning, coding and testing. Practice Planning game. Release Planning. User stories. Annika Silvervarg

Chapter 4 Objectives

CO328- Human Computer Interaction Michael Kölling Caroline Li. Heuristic Evaluation

Dealing with Bugs. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 27 04/21/2009

Introduction to Assurance

Usability Testing Review

WORKING IN TEAMS WITH CASECOMPLETE AND THE CASECOMPLETE PROJECT SHARING ADDIN. Contents

EVALUATION ASSIGNMENT 2

Automate Transform Analyze

Credit where Credit is Due. Lecture 25: Refactoring. Goals for this lecture. Last Lecture

Midterm Exam Solutions March 7, 2001 CS162 Operating Systems

Question #1: 1. The assigned readings use the phrase "Database Approach." In your own words, what is the essence of a database approach?

3,500. The Developer Division at Microsoft

The Crossed Swords wargame: Catching NATO red teams with cyber deception

WHITE PAPER DATA DICATIONARY DEFINING AND USING A COMMON LANGUAGE

DOWNLOAD PDF LEARN TO USE MICROSOFT ACCESS

Transcription:

1 Lecture 23: Domain-Driven Design (Part 1) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2005 2 Goals for this lecture Introduce the main concepts of Domain-Driven Design Model-Driven Design Ubiquitous Language Present examples that illustrate these concepts Goals for the Domain-Driven Design Lectures Cover chapters 1-7 and parts of chapter 10 in 4 lectures!

3 Domain-Driven Design Eric Evans, the author of Domain-Driven Design, has been programming and designing systems for 25 years He asserts that for most software projects, the primary focus should be on the domain and domain logic Domain-driven design flows from the premise that the heart of software development is knowledge of the subject matter and finding useful ways of understanding that subject matter. The complexity that we should be tackling is the complexity of the domain itself -- not the technical architecture, not the user interface, not even specific features. This means designing everything around our understanding and conception of the most essential concepts of the business and justifying any other development by how it supports that core. From <http://domaindrivendesign.org/articles/blog/evans_eric_ddd_and_mdd.html> 4 Model-Driven Design Domain-Driven Design leads to Model-Driven Design since developers capture their knowledge of a domain in models In particular A model-driven design is software structured around a set o domain concepts A model-driven design for a UI framework is one in which UI concepts, such as windows and menus, correspond to software constructs Model-driven design embeds a domain model into the very fabric of a software system. This creates a feedback loop between learning about a domain and implementing a system that addresses a problem in that domain Teams who embrace model-driven design are aware that a change to the code IS a change to the model (and vice versa)

5 Model Benefits in DDD The model and its implementation shape each other The link between model and code makes the model relevant and ensures that the work spent on analysis is not wasted Indeed, the results of your analysis are present in the developed system! The model creates a language used by all team members The language spreads domain knowledge throughout a team It allows developers to speak to domain experts (e.g. users) without translation The model is distilled knowledge Analysis is hard; we need to capture the information we get from it The model is the team s agreed-upon way of structuring domain knowledge and and distinguishing the elements of most interest 6 Tackling Complexity The heart of software is its ability to solve domain-related problems for its users Software functionality either solves a domain-related problem or performs a domain-related task All other features support these two goals When a domain is complex, it becomes difficult to accomplish this To be successful, developers must steep themselves in the domain Problem: Most developers are not interested in this! Domain work is messy and demands a lot of knowledge not necessarily related to computer science Developers enjoy quantifiable problems that exercise their technical skills! Evans asserts that domain complexity has to be tackled head-on by developers or they risk irrelevance!

7 Crunching Knowledge Domain modeling requires processing (crunching) knowledge In the same way that financial analysts crunch numbers to, e.g., understand the quarterly performance of a corporation While speaking with domain experts, a domain modeler will try one organizing idea (set of concepts) after another create models, try them out, reject some, transform others Success is achieved when the modeler has created a set of abstract concepts that makes sense of all the details provided by the domain experts Domain experts are a critical part of the process Without them, developers tend to create models with concepts that seem naive and shallow to domain experts 8 Ingredients of Effective Modeling Bind the model and the implementation As a model is developed, create rapid prototypes that test the domain These prototypes contain primarily domain concepts no UI, no persistence, no infrastructure Chapter 3 begins with a story of what happens when you don t do this! Cultivate a language based on the model Domain experts teach you their concepts and vocabulary You teach them the basics of class diagrams and sequence diagrams (via the use of lots of examples) Eventually either side can take terms straight out of the model, organize them into sentences consistent with the structure of the model, and be unambiguously understood without translation

9 Ingredients of Effective Modeling, continued Develop a knowledge-rich model The objects of your model should have behavior and may follow rules The model should not be just a data schema (think class diagram) but should express behavior, constraints, etc. that help solve domainrelated problems Distill the model It will be easy to add concepts to a model but more important is learning to remove concepts that are no longer useful Be willing to brainstorm and experiement Try out variations of the model with rapid prototypes; think of the model as a laboratory that can enable domain-related experiments Use the results of those experiments to evolve the model 10 Example: PCB Design Chapter 1 contains a brief example of domain-driven design when the author was working with a team of printed-circuit board designers Evans knew nothing about electronic hardware Initial conversations with the designers were difficult Evans was not an electrical engineer and didn t understand the designers concepts or skills The designers were not software developers and could not explain the functionality they needed very well The first breakthrough came with Evans noticing that the concept of a Net kept appearing in the reports that the designers wanted from the software system A net on a PCB is a wire conductor that connects a set of components and can carry an electric signal to each component its connected to

11 Example continued This breakthrough led to a sequence of class diagrams and interaction diagrams that eventually led to a greater understanding of the domain PLUS identified a problem within the domain that needed solving See pages 7-11 of domain-driven design The concepts included component type (pin map), component instance, pin, net The problem was detecting the number of hops a signal caused across the components of a PCB One concept, net topology, was dropped when the developer discovered it wasn t needed to solve this problem 12 Knowledge-Rich Design To repeat, models capture more information than just the classes of a domain As Evans says, it goes beyond the find the nouns and verbs heuristic of some object-oriented models In particular, models capture behavior, business activities, and business rules (policies, constraints, etc.) This makes knowledge crunching difficult since there may be inconsistencies between business rules Domain experts (workers) can often detect these inconsistencies and apply common sense or create policies to deal with inconsistencies when they arise Software can t do this! (At least not easily!)

13 Example: Modeling Business Rules Consider a simple domain: Booking cargo on ships Voyage * Cargo The associated application might have code that looks like this: public int makebooking(cargo cargo, Voyage voyage) { int confirmation = getordernumber(); voyage.addcargo(cargo, confirmation); return confirmation; } 14 Example, continued A standard practice in the shipping industry is to accept more cargo than a particular ship can carry on voyage This is know as overbooking and is used because there are typically always last-minute cancellations One way of specifying the overbooking policy is via a percentage of the ship s total capacity So, if a requirements documents says Allow 10% overbooking our code might change to look like this public int makebooking(cargo cargo, Voyage voyage) { double maxbooking = voyage.capacity() * 1.1; if ((voyage.bookedcargosize() + cargo.size()) > maxbooking) return -1;... }

15 Problem: Hidden Knowledge The problem with this approach is that the overbooking policy is not reflected in our model The policy has been recorded in a requirements document and hidden away inside one method in our application Domain-Driven Design recommends making that knowledge a part of the model: change the model, change the code (and vice versa) Voyage * Cargo {sum(cargo.size) < voyage.capacity * 1.1} Overbooking Policy 16 Example, continued Our code would now look like this public int makebooking(cargo cargo, Voyage voyage) { if (!overbookingpolicy.isallowed(cargo, voyage)) return -1... } and the OverbookingPolicy class would have this method: public boolean isallowed(cargo cargo, Voyage voyage) { return (cargo.size() + voyage.bookedcargosize()) <= (voyage.capacity() * 1.1); }

17 Ubiquitous Language A core piece of domain-driven design is the symbiotic nature of the model being created for your software system and the language used by developers to discuss the system under design Evans states Use the model as the backbone of a language. Commit the team to exercising that language relentlessly in all communication within the team and in the code. Use the same language in diagrams, writing, and especially speech Iron out difficulties by experimenting with alternative expressions, which reflect alternative models. Then refactor the code, renaming classes, methods, and modules to conform to the new model This allows developers to use their linguistic abilities to aid software design, resolving ambiguity or confusion over terms in conversation See example on pages 27 to 30 18 Merging Jargons Ubiquitous Language technical aspects of design technical terms design patterns domain concepts "big picture" view of system subdomains business terms developers don't understand familiar business terms not relevant to the system under design Solution Space Problem Space

19 Using Language to Refine a Model When working on a model, speak the relationships out loud until you ve captured requirements in a concise way Three examples (from bad to good) If we give the Routing Service an origin, destination, and arrival time, it can look up the stops the cargo will have to make and, well... stick them in the database. The origin, destination, and so on... it all feeds into the Routing Service, and we get back an Itinerary that has everything we need in it A Routing Service finds an Itinerary that satisfies a Route Specification Once you ve got a statement like the last, you can supplement with additional statements A Routing Service needs an origin, a destination, and an arrival time 20 One Team, One Language Developers will want to hide the model from the domain experts The model is too abstract for them They don t understand objects We have to collect requirements in their terminology Recall that the model is supposed to describe the user s domain! If sophisticated domain experts don t understand the model, something is wrong with the model! Indeed, the domain experts will be your best resource for testing the adequacy of a model They will quickly find problems, notice ambiguity, identify naive assumptions, etc.

21 Documents and Diagrams Diagrams are good for anchoring discussions about the model brainstorming changes to the model But diagrams can t capture everything attributes and relationships tell half the story because behavior and constraints are not easily illustrated You can diagram some behaviors but you can t diagram all of them! The vital detail about the design is captured in the code! Documents are needed to capture decisions in large groups but beware entropy! Documents often get left behind! Good documents provide background and record the thinking behind decisions; they should not try to replace code s ability to provide detail See example page 42 22 What s Next Review the contents of Part II of Domain-Driven Design The Building Blocks of a Model-Driven Design Layered Architecture Entities, Value Objects, Services, Modules Life Cycles of Domain Objects Aggregates Factories Repositories