Architecting and Implementing Domain-driven Design Patterns in.net

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

Lecture 23: Domain-Driven Design (Part 1)

Designing the M in MVC

Discovering the domain architecture

BUILDING MICROSERVICES ON AZURE. ~ Vaibhav

Ten good practices for ASP.NET MVC applications

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

Creating Models. Rob Allen, July 2014

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

Domain Events & Event Storming. Michael

OBJECT-ORIENTED DOMAIN DRIVEN DESIGN. Robert Bräutigam MATHEMA So ware GmbH.

Archer Configuration Best Practices

New frontier of responsive & device-friendly web sites

Lesson 14 SOA with REST (Part I)

marketing versus marketing automation What s the difference and why should B2B marketers care?

ONLINE BOOKING GUIDE

Systems software design

NOSQL DATABASE SYSTEMS: DATA MODELING. Big Data Technologies: NoSQL DBMS (Data Modeling) - SoSe

Enabling industry 4.0 Event-driven architectures and smart micro services

Digital Workflow 10 Tech Rules to Guide You

COPYRIGHTED MATERIAL CONTENTS PART I: THE PRINCIPLES AND PRACTICES OF DOMAIN DRIVEN DESIGN

CTL.SC4x Technology and Systems

AntiPatterns. EEC 421/521: Software Engineering. AntiPatterns: Structure. AntiPatterns: Motivation

NoSQL systems: introduction and data models. Riccardo Torlone Università Roma Tre

Extreme programming XP 6

Clean Architecture Patterns, Practices, and #sddconf

Clean Architecture Patterns, Practices, and #DevSum17

Software LEIC/LETI. Lecture 20

SAP. Modeling Guide for PPF

Complex event flows in distributed systems

UNCHAIN (MY HEART) You were not made to live as brutes, but to follow virtue and knowledge Dante, Inferno XXVI, Ulysses DINO ESPOSITO

Web Application Design. Husni Husni.trunojoyo.ac.id

THINGS YOU NEED TO KNOW ABOUT USER DOCUMENTATION DOCUMENTATION BEST PRACTICES

FIVE REASONS YOU SHOULD RUN CONTAINERS ON BARE METAL, NOT VMS

B. What strategy (order of refactorings) would you use to improve the code?

Cloud Computing the VMware Perspective. Bogomil Balkansky Product Marketing

Oracle Forms and Oracle APEX The Odd Couple

Copyright 2014 Blue Net Corporation. All rights reserved

Avancier Methods. Very basic design patterns. It is illegal to copy, share or show this document

Lesson 2. Introducing Apps. In this lesson, you ll unlock the true power of your computer by learning to use apps!

Management Information Systems Review Questions. Chapter 6 Foundations of Business Intelligence: Databases and Information Management

Unit 6 - Software Design and Development LESSON 1 INTRODUCTION

Microservices Beyond the Hype. SATURN San Diego May 3, 2016 Paulo Merson

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

Bots. Table of Contents

monolith to micro-services? event sourcing can help Doug

J2EE AntiPatterns. Bill Dudney. Object Systems Group Copyright 2003, Object Systems Group

TestComplete 3.0 Overview for Non-developers

15 Minute Traffic Formula. Contents HOW TO GET MORE TRAFFIC IN 15 MINUTES WITH SEO... 3

Understanding. Domain-Driven Design

DDD and BDD. Dan North ThoughtWorks

Microservices. SWE 432, Fall 2017 Design and Implementation of Software for the Web

5. Application Layer. Introduction

ASP.NET Core Should I stay or should I go?

Web Host. Choosing a. for Your WordPress Site. What is web hosting, and why do you need it?

Quick UX wins for myshopi, the n 1 promotions & shopping list platform

Falling Out of the Clouds: When Your Big Data Needs a New Home

I CAN T FIND THE #$%& DATA. Why You Need a Data Catalog

Making sense of chaos An evaluation of the current state of information architecture for the Web

Testing System Qualities

Comparing Application Frameworks. Sean A Corfield An Architect's View

Furl Furled Furling. Social on-line book marking for the masses. Jim Wenzloff Blog:

9 R1 Get another piece of paper. We re going to have fun keeping track of (inaudible). Um How much time do you have? Are you getting tired?

Reengineering II. Transforming the System

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

.NET Three Examples of Applied Patterns Jimmy Nilsson

Introduction to Software Engineering: Analysis

Function. Description

McCa!"s Triangle of Quality

Audience: Info Workers, Dev

You might already know that tables are organized into vertical columns and horizontal rows.

Handout 12 Data Warehousing and Analytics.

Science-as-a-Service

Not Your Grandma s

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

PAIRS AND LISTS 6. GEORGE WANG Department of Electrical Engineering and Computer Sciences University of California, Berkeley

What are the characteristics of Object Oriented programming language?

READYNAS SOLUTIONS SERIES. Simplifying Backups. Infrant Technologies, Inc Skyway Court, Fremont, CA

Application Architectures, Design Patterns

Web Presentation Patterns (controller) SWEN-343 From Fowler, Patterns of Enterprise Application Architecture

Database Architectures

Life as a Service. Scalability and Other Aspects. Dino Esposito JetBrains ARCHITECT, TRAINER AND CONSULTANT

Foundations. The Golden Record is Not Enough: The Case For Data Orchestration. CPDAs Highly Recommend

SCALABLE DATABASES. Sergio Bossa. From Relational Databases To Polyglot Persistence.

This chapter is intended to take you through the basic steps of using the Visual Basic

Are You Avoiding These Top 10 File Transfer Risks?

NoSQL & Firebase. SWE 432, Fall Web Application Development

Class diagrams and architectural design

Distributed CI: Scaling Jenkins on Mesos and Marathon. Roger Ignazio Puppet Labs, Inc. MesosCon 2015 Seattle, WA

Data Warehouses Chapter 12. Class 10: Data Warehouses 1

May Web Service Users,

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

Big Data Integration Patterns. Michael Häusler Jun 12, 2017

THE DUAL MODEL ARCHITECTURE

Project # 1: Database Programming

Announcements. Teams formed (sit with your group from now on) Project Deliverables

Managing Data at Scale: Microservices and Events. Randy linkedin.com/in/randyshoup

On to OO design ideas. Really just an introduction (much more in CS 48) About programming in the large

Fast Track to EJB 3.0 and the JPA Using JBoss

Getting Help...71 Getting help with ScreenSteps...72

Transcription:

Architecting and Implementing Domain-driven Design Patterns in.net Dino Esposito JetBrains dino.esposito@jetbrains.com @despos facebook.com/naa4e

WARNING This is NOT simply a shameless plug but a truly helpful reference I will say that in a number of cases, a page from this book erased a mass of confusion I'd acquired from Vaughn Vernon's Implementing Domain-Driven Design. This was written in a much more concise, clear, practical manner than that book. (non anonymous) Amazon reviewer

http://naa4e.codeplex.com

http://www.laputan.org/pub/foote/mud.pdf Big Ball of Mud (BBM) A system that s largely unstructured, padded with hidden dependencies between parts, with a lot of data and code duplication and an unclear identification of layers and concerns a spaghetti code jungle.

Why Is DDD So Intriguing? Captures known elements of the design process Domain modeling is the focus of development Organizes them into a set of principles Different way of building business logic

The Secret Dream of Any Developer An all-encompassing object model describing the entire domain Time Data-centric design patterns Domain-driven design patterns Give me enough time and enough specs and I ll build the world for you. Complexity NOTE: Adapted from Martin Fowler s PoEAA

Supreme Goal Tackling Complexity in the Heart of Software Wonderful idea Not a mere promise Not really hard to do right But just easier to do wrong

DDD Is Still About Business Logic 1 2 3 4 Crunch knowledge about the domain Recognize subdomains Design a rich domain model Code by telling objects in the domain model what do to

DDD Key Misconception It s all about using objects and hardcode business behavior in objects. Persistence? External services Cross-objects business logic? Business events?

Book a court New Booking object created How do you get the ID of the booking? DESIGN DOMAIN PERSISTENCE

DESIGN DRIVEN BY THE DOMAIN

Start from User Requirements Noun Verb Registered Customer Redeem Voucher Order Place Pay Official name is voucher Synonyms like coupon or gift card are not allowed. Ordered Items

At Work Defining the Ubiquitous Language Delete the booking Submit the order Update the job order Create the invoice Set state of the game Cancel the booking Checkout Extend the job order Register/Accept the invoice Start/Pause the game

DEMO How would you define a model for a sport match?

Problem Space Solution Space Domain Domain Model Subdomain Subdomain Bounded Context Bounded Context

Ubiquitous language Bounded Context Independent implementation (e.g., CQRS) External interface (to other contexts)

Key facts for Domain-driven Design Patterns Mirroring Tasks Events Pragmatism vs. vs. vs. vs. Modeling Objects Models Ideology Requirements Context Map Implementation

Context map is the diagram that provides a comprehensive view of the system being designed U Core Domain U Weather Forecasts (external) U D D ACL D Backoffice Club Site

Model for the Domain Patterns TX Script Table Module Domain Model CQRS Event Sourcing Layered Architecture Presentation UX Application Use-cases Business Domain Infrastructure Persistence Polyglot persistence Relational NoSQL Memory

Business Logic An Abstract Definition Application Logic Dependent on use-cases Domain Logic Invariant to usecases Application entities Application workflow components Business entities Business workflow components

Business Logic DDD Definition Application Logic Dependent on use-cases Data transfer objects Application services Domain Logic Invariant to use-cases Domain model Domain services

Transaction Script Pattern System actions Each procedure handles a single task Logical transaction end-to-end from presentation to data Common subtasks split into bounded sub-procedures for reuse

Table Module Pattern One module per table in the database Module contains all methods that will process the data Both queries and commands May limit modules to significant tables Tables with only outbound foreign-key relationships Recordset-like objects PRESENTATION APPLICATION TX SCRIPT TX SCRIPT TX ORDERS SCRIPT MODULE Workflows & rules

Domain Model Pattern Aggregated objects Data and behavior Persistence agnostic Paired with domain services Aggregate Some rules TX Aggregate SCRIPT SERVICE TX Aggregate SCRIPT SERVICE Workflows & rules

Domain Layer Logic invariant to use-cases Domain model Domain services Not necessarily an implementation of the Domain Model pattern Takes care of persistence tasks

Domain Model Models for the business domain Object-oriented entity model Functional model Guidelines for classes in an entity model Anemic model DDD conventions (factories, value types, private setters) Data and behavior Plain data containers Behavior and rules moved to domain services

Domain Services Pieces of domain logic that don t fit into any of the existing entities Classes that group logically related behaviors Implementation of processes that Typically operating on multiple domain entities Require access to the persistence layer for reads and writes Require access to external services

DEMO

Aggregates Ensure business consistency Transactional consistency only, within the domain Work with fewer and coarse-grained objects Aggregate root encapsulates child entities Fewer entity-to-entity relationships to care about An aggregate is a cluster of associated objects that we treat as a single unit for the purpose of data changes. E. Evans

Domain Events Something noteworthy within the domain Simplest is notification of CRUD operations Relevant as it helps scheduling complex operations in a more natural way Requires ad hoc infrastructure in domain model classes

At the end of the day The key lesson today is being aware of emerging new ways of doing old things. Not because you can no longer do the same old things in the same known way, but because newer implementation may let the system evolve in a much smoother way saving you a BBM and some maintenance costs.

Thank You! FOLLOW @despos facebook.com/naa4e dino.esposito@jetbrains.com software2cents.wordpress.com http://naa4e.codeplex.com/ Project MERP