Domain Driven Design. Informatik IT-Uddannelse og IT-Udvikling



Similar documents
Serialization. Informatik IT-Uddannelse og IT-Udvikling

Creating Models. Rob Allen, June 2014

Windows Forms 2.0 Data Binding. Informatik IT-Uddannelse og IT-Udvikling

Patterns of Enterprise Application Architecture

CSCI 5828 Spring 2010 Foundations of Software Engineering. - Arpit Sud

Architecture Rules Enforcement and Governance Using Aspects

Security in Domain-Driven Design. Author: Michiel Uithol

Integration of Application Business Logic and Business Rules with DSL and AOP

Software Service Engineering Architect s Dream or Developer s Nightmare?

Independent Insight for Service Oriented Practice. An SOA Roadmap. John C. Butler Chief Architect. A CBDI Partner Company.

Software Life-Cycle Management

How To Design Your Code In Php (Php)

Patterns & Techniques for Separating Business Logic in New SOA System Development. Iyad Jabri Intelliun Corporation CEO

Government's Adoption of SOA and SOA Examples

A place for everything, everything in its place Benjamin Franklin

A Reference Architecture for Self-organizing Service-oriented Computing

How To Use An Informix System With A Computer System (For A Dba)

SOA-14: Continuous Integration in SOA Projects Andreas Gies

An Overview of SAP BW Powered by HANA. Al Weedman

SOACertifiedProfessional.Braindumps.S90-03A.v by.JANET.100q. Exam Code: S90-03A. Exam Name: SOA Design & Architecture

SOA REFERENCE ARCHITECTURE: WEB TIER

Shopping Cart. Analysis & Design. Author:John Smith P08/ Version:1.7 Status:Draft Publication:23/05/2013 Copyright:Modeliosoft

Chapter 6 Basics of Data Integration. Fundamentals of Business Analytics RN Prasad and Seema Acharya

Object Oriented Database Management System for Decision Support System.

Plan-Driven Methodologies

Service Oriented Architecture and the DBA Kathy Komer Aetna Inc. New England DB2 Users Group. Tuesday June 12 1:00-2:15

Data Governance and CA ERwin Active Model Templates

Programming Without a Call Stack: Event-driven Architectures

Net-WMS FP Net-WMS SPECIFIC TARGETED RESEARCH OR INNOVATION PROJECT. Networked Businesses. D.8.1 Networked architecture J2EE compliant

So we thought we knew money

Does function point analysis change with new approaches to software development? January 2013

Enterprise Application Integration (EAI) Techniques

Monday, April 8, 13. Creating Successful Magento ERP Integrations

Skills for Employment Investment Project (SEIP)

Postgres Plus Advanced Server

September 18, Modular development in Magento 2. Igor Miniailo Magento

OBJECTS AND DATABASES. CS121: Introduction to Relational Database Systems Fall 2015 Lecture 21

MDM Registry Pros and Cons

JOURNAL OF OBJECT TECHNOLOGY

Cloud application services (SaaS) Multi-Tenant Data Architecture Shailesh Paliwal Infosys Technologies Limited

Software Development Best Practices

Building Hyper-Scale Platform-as-a-Service Microservices with Microsoft Azure. Patriek van Dorp and Alex Thissen

Variable Base Interface

Managing a Class Hierarchy with SQL in Matisse

Data Grids. Lidan Wang April 5, 2007

The Lab and The Factory

.NET Overview. David Smith. Today s s Topics. Why am I here? A tool. Microsoft s s Vision for.net

10 Years of Hype Cycles - Do We Forget Knowledge?

Improved SOA Portfolio Management with Enterprise Architecture and webmethods

SOA REFERENCE ARCHITECTURE: SERVICE ORIENTED ARCHITECTURE

MDA Overview OMG. Enterprise Architect UML 2 Case Tool by Sparx Systems by Sparx Systems

Domain-Driven Design

Using IRDB in a Dot Net Project

SOA & Web Services Development Survey

Building Scalable Applications Using Microsoft Technologies

MDM and SOA Timo Itälä T

PMI PMBOK & ESTIMATING PMI PMBOK & ESTIMATING PMI PMBOK & ESTIMATING PMI PMBOK & ESTIMATING PMI PMBOK & ESTIMATING PMI PMBOK & ESTIMATING

ORM IN WEB PROGRAMMING. Course project report for 6WW Erik Wang

Domain driven design, NoSQL and multi-model databases

DSLs to fully generate Business Applications Daniel Stieger, Matthias Farwick, Berthold Agreiter, Wolfgang Messner

What is Data Virtualization? Rick F. van der Lans, R20/Consultancy

Scaling out a SharePoint Farm and Configuring Network Load Balancing on the Web Servers. Steve Smith Combined Knowledge MVP SharePoint Server

Enterprise Data Integration for Microsoft Dynamics CRM

Mobile App Discovery through Conceptual Models

QLIKVIEW ARCHITECTURE AND SYSTEM RESOURCE USAGE

Designing an Enterprise Application Framework for Service-Oriented Architecture 1

What is Data Virtualization?

OVERVIEW OF JPSEARCH: A STANDARD FOR IMAGE SEARCH AND RETRIEVAL

1. Introduction What is Slice? Background Why Slice? Purpose of this Document Intended Audience...

Der Mythos vom Re-Use

OSLC ALM-PLM Interoperability Proof of Concept. Mike Loeffler Systems Engineering IT Specialist General Motors Company

Service Oriented Architecture 1 COMPILED BY BJ

Advanced IT Pro Course for Office SharePoint Server 2007 and SharePoint Services 3.0

the smarter way to manage enterprise APIs for SYSPRO ebook

Types & Uses of Databases

Building Out BPM/SOA Centers of Excellence Business Driven Process Improvement

COSC 6397 Big Data Analytics. 2 nd homework assignment Pig and Hive. Edgar Gabriel Spring 2015

Analysis and Design of Software Systems Practical Session 01. System Layering

Software Architect Track

Motivation Definitions EAI Architectures Elements Integration Technologies. Part I. EAI: Foundations, Concepts, and Architectures

Raima Database Manager Version 14.0 In-memory Database Engine

Track and Keynote/Session Title 9:00:00 AM Keynote 11g Database Development Java Track Database Apex Track.Net Track. 09:30:00 AM with Oracle and

A Beginners Guide to Fusion Middleware

Data Management in the Cloud

Enterprise Application Development In Java with AJAX and ORM

Computer Information Systems (CIS)

... Introduction... 17

Transcription:

Domain Driven Design

Morten Mertner Senior Consultant, Teknologisk Institut - Architect and Software Developer (C#) - Teacher - Speaker (conferences and gatherings) Certifications - MSCD.NET - MCT Open Source - Gentle.NET (object persistence framework / object-relational mapper) - MbUnit (unit test framework)

Agenda Domain Driven Design - Introduction - Patterns - Entity and ValueObject - Repository - Specification - Extensions - Factory - Conclusion - Domain Models and SOA

TransactionScript vs Domain Model Transaction Script - procedural - simple and easy to understand - minimal performance overhead - often results in cut & paste reuse (hard to maintain) - does not scale to complicated tasks Domain Model - logic organised in units that cooperate to solve business operations and rules - concepts in problem domain are modelled as classes - true object-orientation

TransactionScript vs Domain Model

Introduction Patterns - Entity - ValueObject - Repository - Specification

DDD Entity Entity - uniquely identifyable (has identity) - equality comparison uses identity (not attribute values) - usually extended longevity Examples - Product - Customer - Order

Example: Order = Entity class Order { Customer customer; List<OrderLineItem> lineitems; public Order( Customer customer ) { this.customer = customer; lineitems = new List<OrderLineItems>(); public void AddLineItem( OrderLineItem li ) { lineitems.add(li); public void RemoveLineItem( OrderLineItem li ) { lineitems.remove(li); public IList<OrderLineItem> LineItems{ get { return lineitems; public float GetTotalPrice() { float result = 0; foreach( OrderLineItem li in lineitems ) { result += li.price; return result;

DDD ValueObject ValueObject - no identity - equality comparison uses attribute values - describes entities - should be immutable Example - OrderLineItem

Example: OrderLineItem = ValueObject class OrderLineItem { int quantity; Product product; float price; public OrderLineItem( Product p, int quantity, float price ) { this.product = p; this.quantity = quantity; this.price = price; public int Quantity { get { return quantity; public Product Product { get { return product; public float Price { get { return price;

DDD Entity & ValueObject

DDD Repository Repository - responsible for object persistence - interface similar to collection class - creates an illusion of all objects being in memory Example - CustomerRepository - ProductRepository - OrderRepository

Repository public interface IRepository<T> { void Add( T newelement ); void Remove( T element ); void Remove( int oid ); T FindByOID( int oid ); IList<T> Select(... ); public class AbstractRepository<T> : IRepository<T> { // implemenation code public class CustomerRepository : AbstractRepository<Customer> { public class OrderRepository : AbstractRepository<Order> { public class ProductRepository : AbstractRepository<Product> {

DDD Repository

DDD Specification Specification - business rule (encapsulated in an object) Purpose - data query - validation

DDD Specification interface ISpecification<T> { bool IsSatisfiedBy( T domainobject ); class GoldCustomerSpecification : ISpecification<Customer> { public bool IsSatisfiedBy( Customer customer ) { return customer.totalorderamount > 10000;

DDD Repository + Specification public interface IRepository<T> { void Add( T newelement ); void Remove( T element ); void Remove( int oid ); T FindByOID( int oid ); IList<T> Select( ISpecification<T> spec ); public class AbstractRepository<T> : IRepository<T> { // implemenation code public class CustomerRepository : AbstractRepository<Customer> { public class OrderRepository : AbstractRepository<Order> { public class ProductRepository : AbstractRepository<Product> {

Specification with Persistence Support interface ISpecification<T> { bool IsSatisfiedBy( T domainobject ); bool HasQuerySupport { get; string querystring { get; // ADO.NET interface ISpecification<T> { bool IsSatisfiedBy( T domainobject ); bool HasQuerySupport { get; Expression Criteria { get; // ORM (Gentle.NET 2.0)

RepositoryFactory RepositoryFactory - avoids coupling between entities in data access code - clean encapsulation of all database code - database provider independence (ADO.NET) - ORM independence

RepositoryFactory public interface IRepositoryFactory { IRepository<T> GetRepository<T>( T entitytype ); public class RepositoryFactory { IRepository<T> GetRepository<T>( T entitytype ) { return new GentleRepository<T>();

Usage // create new order Order order = new Order(); order.addlineitem( new OrderLineItem( product, 5, 50.0 ) ); OrderRepository orderrepository = RepositoryFactory.GetRepository<Order>(); orderrepository.add( order ); // find all gold customers CustomerRespository cr = RepositoryFactory.GetRepository<Customer>(); IList<Customer> goldies = cr.select( new GoldCustomerSpecification() ); // check whether a given customer is a gold customer Customer customer = ; if( new GoldCustomerSpecification().IsSatisfiedBy( customer ) ) {

Domain Models Advantages - provides sufficient abstraction to deal with complex problem domains - scales to very large code bases - common language between developers and domain experts - once mastered it is a powerful tool you rarely develop any other way Disadvantages - mapping domain objects to a relational database is difficult and timeconsuming (unless you use an ORM tool) - takes skill and effort to understand, experience to master

Domain Models and SOA

Resources Eric Evans Domain Driven Design http://domaindrivendesign.org/book/ Martin Fowler Patterns of Enterprise Application Architecture http://martinfowler.com/books.html#eaa Steve Eichert (blog) http://steve.emxsoftware.com/domain+driven+design Kim Harding Christensen, EOS

Implementation Gentle.NET 2.0 - open source ORM - working implementation ISpecification - ISpecification is called IFilter - IFilter supports Combine/Remove/Sort (both in-memory and data) - IObjectIdentity used to abstract object identifier (here we used int)

Implementation Source Code http://www.mertner.com/svn/gentle/gentle/ SourceBranches/2.0.0/Gentle.Persistence/Client/Repository/*.cs http://www.mertner.com/fisheye Documentation http://www.mertner.com/confluence/display/gentle/design+recommendations

Questions?

Thoughts & Unsolved Problems Transactions - transaction initiation and participation - cross-repository transactions - automatic enlisting Generics - make it difficult to put repository in base class - slightly more cumbersome than using non-generic classes RelationFilter - requires ability to modify not just the where-clause of queries