Domain Driven Design and Persistance. How do you do it?
-
I am interested in knowing how you design your Domain Model and its persistance layer. Particularly I design the Domain Model completely independent from any other logical application layer. As a matter of fact, it is oblivious of any other logical layer. In that case I do create a service layer that acts as a proxy and sends domain model objects to the persistence layer. I've seen Dependency Injection/IoC to perform the persistence, having the interface defined in the Domain Model, but I never really liked this approach, because it creates a small dependence of interface implementation by the persistence layer. Do you have "Save" methods on your Domain Objects? I'd appreciate if you shared your thoughts.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
-
I am interested in knowing how you design your Domain Model and its persistance layer. Particularly I design the Domain Model completely independent from any other logical application layer. As a matter of fact, it is oblivious of any other logical layer. In that case I do create a service layer that acts as a proxy and sends domain model objects to the persistence layer. I've seen Dependency Injection/IoC to perform the persistence, having the interface defined in the Domain Model, but I never really liked this approach, because it creates a small dependence of interface implementation by the persistence layer. Do you have "Save" methods on your Domain Objects? I'd appreciate if you shared your thoughts.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
Hi, If you are using relational database system like MySQL, Oracle, consider using an Object-Relational Mapping framework(ORM) that implements Data Acess Layer(DAL) design pattern . TopLink, Hibernate, ADO.Net, Java JPA, just to name a few, are popular ORM Frameworks. These frameworks abstract DBMS access and handle all database CRUD for you, and do much more. For example using Java JPA, you would save a domain object as follow: EntityManager em; em.persist(BookDTO);// BookDTO is the object to be saved in you database. BookDTO must be annotated as an Entity( @Entity) as far as JPA is concern. You can apply Dependency Injection/IoC to inject the EntityManager in your component. To use DAL patern organize your Domain Model into Business Object(BO) and Data Transfer Object(DTO), and utilize an ORM framework of your choice.
Bakary Konate
-
I am interested in knowing how you design your Domain Model and its persistance layer. Particularly I design the Domain Model completely independent from any other logical application layer. As a matter of fact, it is oblivious of any other logical layer. In that case I do create a service layer that acts as a proxy and sends domain model objects to the persistence layer. I've seen Dependency Injection/IoC to perform the persistence, having the interface defined in the Domain Model, but I never really liked this approach, because it creates a small dependence of interface implementation by the persistence layer. Do you have "Save" methods on your Domain Objects? I'd appreciate if you shared your thoughts.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia
Hi, At work I have created a homebrew framework ColdBlood with various object oriented design features; one is persistency. In the specification (interface) of each object type we differ between properties, references, child and children. We do this using different attributes (in C#). A property can have the optional flag Persistent enabled, which means this property is serializable. All the specification attributes are compiled into some info classes for fast lookup e.g. by the serializer/deserializer. This design means a complete separation of persistency specification and serializer/deserializer implementation. Currently, we use a serializer/deserializer implementation with multiple ToBytes and FromBytes methods. The resulting byte data can be transfered to/from files or sockets. Kind Regards, Keld Ølykke