EF6 and DDD

31

Transcript of EF6 and DDD

EF 6 i DDD

Framework i arhitektura za

poslovne aplikacije

Agenda

• DDD

– DDD koncepti i obrasci (patterns)

– Arhitektura

• EF 6 novosti

• Oblikovanje EF prema DDD konceptima

– Bounded Context

– Aggregate roots

– Value object & entities

• DEMO

DDD

DDD

Koncepti

• Ubiquitous Language

• Bounded Contexts

• Persistance ignorance

• Refactoring

• CQS

• Kada upotrijebiti DDD?

Patterns

• Entities

• Value objects

• Aggregate roots

• Repository

• Domain Services

• Domain Events

• State

Ubiquitous Language

„ …ordinary classes where you focus on the business problem at hand

without adding stuff for infrastructure-related reasons…

nothing else should be in the Domain Model. ”

Persistance Ingorance

Bounded Context

Aggregates

Aggregate root

*

Repositories

public interface IEmployeeRepository

{

Employee GetById(int id);

void Add(Employee employee);

void Remove(Employee employee);

IEnumerable<Employee> GetStaffWorkingInRegion(Region region);

}

Domain services

Architecture

Tradicionalna 3-slojna arhitektura

Presentation

Business Logic (BLL)

Data Access (DAL)

Infr

astr

uct

ure

Onion arhitektura

User Interface

G

Filesystem

Services

etc

Application Services

M

Domain Services

Domain Model

Database

Onion arhitektura

User Interface

G

Filesystem

Services

etc

Application Services

M

Domain Services

Domain Model

Database

Employee,IEmployeeRepository

NHibernateEmployeeRepository

EmployeeController

IEmailSender

SmtpEmailSender

EF + DDD

• Unit of Work

• Privatni konstruktori

• Privatni set-eri

• Value objects vs Entities

• Kompleksni tipovi

• Repozitoriji vs. CQS

EF Novosti

• DbContext

• Enums, spatial

• Code first

• Migrations

• Mappings, conventions

• Multiple diagrams per model

• Async, perf improvements, Connection Resiliency

• Interceptors, custom configuratiomn, DI

• Open sourced, out of .NET Fx

• Nuget package + VS Tools addon download

„Any fool can write code that a computer

can understand. Good programmers write

code that humans can understand.”

Martin Fowler

DEMO TIME!

Hvala! Pitanja?

• Hrvoje Hudoletnjak

• Twitter.com/hhrvoje

• www.hudosvibe.net

[email protected]

Ne zaboravite ispuniti upitnike.

Čekaju vas vrijedne nagrade!

Resources

• http://www.slideshare.net/JulieLerman/entity-framework-ddd

• http://www.slideshare.net/rdingwall/domain-driven-design-101

• http://www.slideshare.net/panesofglass/domain-driven-design

• http://msdn.microsoft.com/sv-se/magazine/dn342868(en-us).aspx

• https://entityframework.codeplex.com/wikipage?title=specs