80 likes | 225 Views
The Persistence Ignorant Domain Model. James Kovacs JamesKovacs.com jkovacs@post.harvard.edu. What is Persistence Ignorance?. POCO – Plain Old CLR Object No persistence-related code Only business logic public class Customer { public string Name { get; }
E N D
The Persistence IgnorantDomain Model James Kovacs JamesKovacs.com jkovacs@post.harvard.edu
What is Persistence Ignorance? • POCO – Plain Old CLR Object • No persistence-related code • Only business logic public class Customer { public string Name { get; } public Location Address { get; } public IList<Order> Orders { get; } public void AddOrder(Order o) {} }
Why is Persistence Ignorance Important? • Separation of concerns • Single responsibility • Loose coupling • Testability • Re-use
NHibernate and PI • No special persistence-related base class • No marker or callback interfaces • No persistence-related attributes • NHibernate domain class: public class Customer { public string Name { get; } public Location Address { get; } public IList<Order> Orders { get; } public void AddOrder(Order o) {} }
Resources • NHibernate (http://www.nhibernate.org) • NHibernate in Action by Pierre Henri Kuaté, et al. • NHibernatePlugin (http://sourceforge.net/projects/nhibernateaddin) • Castle Active Record (http://www.castleproject.org) • Active Writer (http://altinoren.com/activewriter/) • Domain-Driven Design by Eric Evans • Applying Domain-Driven Design and Patterns by Jimmy Nilsson
Questions James Kovacs JamesKovacs.com jkovacs@post.harvard.edu