domain-driven-design

How to persist event log data in database?

In my application I have a strong requirement for logging each event for the entity and I was considering using event sourcing pattern, i.e. all domain changes have explicit classes and any change to the domain objects can go only using these event classes. You can then rollback and reapply these changes as you want, just like in source ...

What are the benefits of Persistence Ignorance?

Hi, I am a newbie in the DDD+TDD World. But I have been in programming for almost 9 years. Can someone please explain me the benefits of persistance ignornace ? Typical nHibernate application just pushes the dependency between class and database to mapping files. If I change Class files or Database, I have to change the mapping files....

How to model subsets of inter-object relationships.

Hi - Im new to working with Domain Models so forgive me for asking an elementary question. If a Domain Object has a 1-many relationship with another Domain Object but logic that uses the first object works with only a subset of that objects related objects, what is the best way to expose this subset? For example, say a Person is relat...

DDD, Anti Corruption layer, how-to?

At the moment, we have to build an application which is based on a legacy one. Code for that old application should be thrown away and rewritten, but as it usually goes - instead of rewriting it, we need to base something new on it. Recently, we decided to go the DomainDrivenDesign path. So -- anti corruption layer could be a solution ...

Html formating in domain classes

I have a simple address object in my domain that has a ToString() method that returns the address like this: 123 Test Ave Appt 1A Spokane, WA 99201 We will be diplaying this in a webpage on several different occasions so it makes senses to add the functionality somewhere to display the address with Html formatting, but if I where to ad...

passing data in an ntier application

How do you pass data to layers in an n-tier application? I have mapped out 3 different methods. A) generic .net objects generic data tables, Hashtables, generic datasets, strings, ints etc... then using the datasets to fill your business objects which get sent to the UI layer. http://dabbleboard.com/draw?b=eiu165&i=26&c=54...

Did anyone try out DDD with a php application?

Are there any open source php applications that use DDD philosophy? DDD = Domain Driven Design ...

making a clean break from un-normalized wide table

I'll try to keep this example as simple as I can. I'm trying to implement a domain-driven design (a business object to represent each table) in an old VB6 app which follows no OOP patterns. The existing code is written just as you might expect from a 10 year old VB app (i.e. use of ADODB.Recordset with no intellisense for fields). The e...

Avoid circular reference in domain model

Hi, this must be such a common scenario that there's been a lot written about it already, hopefully even a really good pattern. I have a domain model in which a custom container contains entities. For example (properties and interfaces excluded for brevity): class Entity { public int Id; public EntityContainer ParentContainer;...

Email notifications - In the domain object or a service?

I'm looking for recommendations on how to approach the following design problem (using a fictitious example based on stackoverflow). I'd trying to avoid an anemic domain model and seek general "best-practice" advice for this type of case. Scenario: Suppose a new feature is being developed for stackoverflow that sends an email notifica...

Mapping Table Enums in NHibernate

I'm currently building a new app based on a legacy database. In the app, there are many "list" tables that have the following format: table listLanguages { PrimaryId bigint; Item varchar(30); } ...with some sample entries like this: PrimaryId Item 1 English 2 French 3 Spanish ... They were used to p...

In Domain Driven Design when an entity clones itself who adds it to its container?

For example, we have two domain objects: Cell and Body (as in human cell and body). The Body class is just a collection of Cells, e.g. class Body { IList<Cell> cells; public void AddCell(Cell c) { ... } public void RemoveCell(Cell c) { ... } } The Cell has a Split method, which internally creates a clone of itself, e.g. ...

Reporting Services Report against ObjectDataSource in a separate application library

Rather than generate my RS reports by directly accessing a SQL database, I'd like to take advantage of Domain Objects I've already written in another application, where complex business rules and calculations already exist so that I don't have to duplicate that logic in stored procedures and other code. I want to keep it DRY. It would b...

Best practice for Handling NHibernate parent-child collections

So in a typical model where you have a parent that can have many children and a child that can have only one parent, how do you manage the adding of children. I have been using this approach; public class Parent { public Parent() { Children = new List<Child>(); } public IList<Child> Children { get; ...

DDD, value objects and ORM

Value objects got no identity. ORM needs identity to update database. How to trick ORM? (marking Id for value object as internal won't work, cause ORM lives in different assembly and moving it to the same assembly is not acceptable). Thanks in advance. ...

EagerReadDerivation: balancing the benefits with the costs

I'm studying Domain-Driven Design and Distributed DDD for an upcoming Silverlight application I'm going to be working on. The EagerReadDerivation pattern seems like it would improve the scalability of the application, but at the cost of increased complexity. The application will have potentially have thousands of users uploading large ...

Where to expose the results of a specific SQL query in the domain model.

Hi - Which of these examples would be the best way to expose a collection of Orders for a specific Person that contain a specific Product and why? Or maybe there is a better way to do this alltogether? (Sorry I am new to domain modeling). The Orders list is pulled from the database with an SQL query and turned into a List collection. A ...

Domain Services and communication against the database

How do you communicate between a domain service and the database? Do you use a repository the same way it's done from a aggregate root? Or do you put the domain service inside the aggregate root service? ...

In TDD and DDD, how do you handle read-only properties in fakes?

Question How do you handle read-only fields when creating fakes? Background I'm in the beginner stages of using ASP.Net MVC and am using Steven Sanderson's Sports Store and Scott Gu's Nerd Dinner as examples. One small problem that I've just hit is how to work with read-only properties when doing fakes. I'm using LINQToSQL. My interf...

NHibernate Aggregate Traversal (C#)

My application has a very simple model right now and I'm trying to find the best way to traverse through an aggregate. As you can see in my model diagram at the bottom, I have an account, a trip and a list of people attending a trip. I would like to be able to view all of the trips an account is apart of and I have come up with something...