Understanding Persistence Ignorance in Domain Models

Slide Note
Embed
Share

Persistence Ignorance is a concept in software development where domain models do not contain any persistence-related code, focusing solely on business logic. This approach promotes separation of concerns, single responsibility, loose coupling, testability, and reusability. NHibernate and Plain Old CLR Object (POCO) are commonly associated with Persistence Ignorance, offering benefits such as flexible querying options, ease of session management, and integration with database operations.


Uploaded on Oct 07, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. The Persistence Ignorant Domain Model James Kovacs JamesKovacs.com jkovacs@post.harvard.edu

  2. 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) {} }

  3. Why is Persistence Ignorance Important? Separation of concerns Single responsibility Loose coupling Testability Re-use

  4. 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) {} }

  5. NHibernate API Configuration Class for bootstrapping NHibernate ISessionFactory Factory for creating sessions ISession Roughly analogous to a database connection ITransaction Abstracts underlying transaction semantics String-based query API IQuery ICriteria Object-based query API

  6. Resources NHibernate (http://www.nhibernate.org) NHibernate in Action by Pierre Henri Kuat , et al. NHibernate Plugin (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

  7. Questions James Kovacs JamesKovacs.com jkovacs@post.harvard.edu

Related