Download presentation
Presentation is loading. Please wait.
Published bySibyl Cannon Modified over 9 years ago
1
http://www.umlchina.com Building an Offline Smart Client using Domain-Driven Design Principles Tim McCarthy
2
Agenda 1.DDD Definitions/Patterns 2.The SmartCA Application 3.Designing the Layered Architecture 4.WPF and the Model-View-ViewModel Pattern 5.Synchronizing the Data
3
Agenda 1.DDD Definitions/Patterns 2.The SmartCA Application 3.Designing the Layered Architecture 4.WPF and the Model-View-ViewModel Pattern 5.Synchronizing the Data
4
What is Domain-Driven Design (DDD)? Sponsor Logo
5
Why Domain-Driven Design (DDD)? Most development time is still spent writing plumbing code instead of business logic Typically, the UI will change a LOT more than the business logic The model is a great tool for communication between developers and users .NET has good support for it!
6
Ubiquitous Language Common terms between business experts and development team Use the language in your code Namespaces Class, property, method, variable names
7
Communicating the Language Create whiteboard drawings Favor whiteboarding over Visio Use digital camera to capture, then paste into Word Use Visual Studio class diagrams for core parts of the domain Code and diagram are kept in sync No wasted time diagramming, your diagram is the code
8
Definition: Entities An object defined primarily by its identity Not its attributes Could be a person, a customer, an order, etc. Not all objects have meaningful identities… In some systems, a class may be an ENTITY, in others maybe not
9
Definition: Value Objects Represent an aspect of the domain with NO conceptual identity Use when you care about what something is, not who they are Same thing as a DTO [Fowler PoEAA] Simple, immutable objects
10
Definition: Aggregates A cluster of associated objects treated as a unit for the purpose of data changes They have a root and a boundary Boundary = what is inside the AGGREGATE Root = single ENTITY inside the AGGREGATE Hardest but most important concept to understand in DDD!
11
Aggregate Rules The root ENTITY has global identity ENTITIES inside the boundary have local identity Nothing outside the AGGREGATE boundary can hold a reference to anything inside, except to the root ENTITY Objects in the AGGREGATE can hold references to other AGGREGATE roots …a few more
12
Definition: Services An operation offered as an interface that stands alone in the model Does not fit into any of the objects in the model Stateless To be used judiciously (do not turn your app into a Transaction Script) Use when an operation is an important domain concept
13
Pattern: Layered Supertype [Fowler 475] Type that acts as the supertype for all types in its layer, i.e. a base class! Factors out common features, such as handling the identity of ENTITIES Example: a common Id property Helps eliminate duplicate code
14
Pattern: Repository Provide access to AGGREGATE roots Represents all objects of a certain type as a conceptual set (usually emulated) Behaves like a collection, e.g. Add(), Remove(), FindBy(id), etc. Persistence Ignorance!
15
Pattern: Layered Architecture
16
Agenda 1.DDD Definitions/Patterns 2.The SmartCA Application 3.Designing the Layered Architecture 4.WPF and the Model-View-ViewModel Pattern 5.Synchronizing the Data
17
The SmartCA Application Problem – Legacy MS Access Application a.k.a. Smart Client Anti-Pattern New System Requirements Technologies Layered Architecture
18
The Legacy Application
19
New System Requirements Reliability and Availability Scalability Maintainability Rich client application functionality Offline Capable Intelligent installation and auto-update functionality Additional client device support
20
The New Solution – SmartCA Application DDD with Layered Architecture UI = WPF Smart Client Data Store Server – behind web services cloud Client – SQL Server Compact Edition 3.5
21
Agenda 1.DDD Definitions/Patterns 2.The SmartCA Application 3.Designing the Layered Architecture 4.WPF and the Model-View-ViewModel Pattern 5.Synchronizing the Data
22
The Layered Architecture Application Layer Domain Layer Repository Strategy Layered Supertype Pattern Infrastructure Layer Presentation Layer
23
Demonstration #1 Layers represented in the SmartCA Visual Studio Solution
24
Repository Framework Interfaces Repository Factory Unit of Work Repository Base Classes
25
Demonstration #2 Repository Framework Implementation
26
Mapping - Entity Factory Framework Interfaces Entity Factory Builder
27
Demonstration #3 Entity Factory Framework Implementation
28
Agenda 1.DDD Definitions/Patterns 2.The SmartCA Application 3.Designing the Layered Architecture 4.WPF and the Model-View-ViewModel Pattern 5.Synchronizing the Data
29
Windows Presentation Foundation (WPF) Declarative Programming (Using XAML) Built-in Command Pattern Strong Data Binding Support
30
Model-View-ViewModel Pattern Traditional Presentation Patterns MVP MVC More… Model-View-ViewModel Definition What’s a ViewModel?
31
Demonstration #4 Model-View-ViewModel
32
Agenda 1.DDD Definitions/Patterns 2.The SmartCA Application 3.Designing the Layered Architecture 4.WPF and the Model-View-ViewModel Pattern 5.Synchronizing the Data
33
Synchronizing the Data – Some Choices SQL Replication ADO.NET Synchronization Services Message-Based Taking advantage of Unit of Work Can talk to any message-based server
34
Message-Base Synchronization
35
Demonstration #5 Data Synchronization
36
Resources [Evans]: Domain-Driven Design: Tackling Complexity in the Heart of Software, Evans, Addison-Wesley (2003) [Fowler]: Patterns of Enterprise Application Architecture, Fowler, Addison- Wesley (2003) [Nilsson]: Applying Domain Driven Design and Patterns: using.NET, Addison Wesley 2006
37
Tim McCarthy, InterKnowlogy Get the Demos & PPT at: Slides: http://www.umlchina.com Code: codeplex.com/dddpdscodeplex.com/dddpds .NET Domain-Driven Design with C#: Problem- Design-Solution.NET Domain-Driven Design with C#: Problem- Design-Solution Contact me: Tim McCarthy E-mail : tmccart1@san.rr.comtmccart1@san.rr.com About Tim McCarthy .NET Architect/Dev Lead/Trainer Author / Speaker MCSD, MCSD.NET, MCDBA, MCT, IEEE CSDP
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.