domain-driven-design

When working with domain models and POCO classes, where do queries go?

I am new to domain models, POCO and DDD, so I am still trying to get my head around a few ideas. One of the things I could not figure out yet is how to keep my domain models simple and storage-agnostic but still capable of performing some queries over its data in a rich way. For instance, suppose that I have an entity Order that has a ...

How do you handle associations between aggregates in DDD?

I'm still wrapping my head around DDD, and one of the stumbling blocks I've encountered is in how to handle associations between separate aggregates. Say I've got one aggregate encapsulating Customers and another encapsulating Shipments. For business reasons Shipments are their own aggregates, and yet they need to be explicitly tied to ...

Is it Possible to Force Properties Generated by Entity Framework to implement Interfaces?

Example Interface: public Interface IEntity Property ID() as Integer end Interface I want all my EF objects to implement this interface on there Primary Keys. Is this possible? ...

How to Organise a Domain Driven Design Project?

Hi Guru's, I've started learning about DDD and wanted to know how others have organised their projects. I've started off by organising around my AggregateRoots: MyApp.Domain (namespace for domain model) MyApp.Domain.Product - Product - IProductService - IProductRepository - etc MyApp.Domain.Comment - Comment - ICommentService - ICo...

Exposing Rich Domain Objects as a service

I’ve been trying to wrap my head around how to expose my domain objects to the client. Whether I’m using a rich client or I’m using the web, I want to use the MVP and repository patterns. What I’m trying to wrap my head around is how I expose my repository and model, which will be on the server. Is it even possible to expose complex b...

Should rules like "A parent object will have up to 2 children" be duplicated in database

Rules like "A parent object will have up to 2 children" could be enforced in database using triggers. But would it be a good idea to duplicate the rule if this rule is already enforced in the domain layer. In which cases duplication of such rules are justified? Are there any alternative to avoid such duplication? Is it not a data integ...

How to implement an offline reader writer lock

Some context for the question All objects in this question are persistent. All requests will be from a Silverlight client talking to an app server via a binary protocol (Hessian) and not WCF. Each user will have a session key (not an ASP.NET session) which will be a string, integer, or GUID (undecided so far). Some objects might ta...

Good Domain Driven Design samples

I'm learning about DDD and enjoying every minute of it. However, there are some practical issues that are confusing to me that I think seeing some good samples might clear up. So being at peace with those issues, does anyone know of some good working code samples that do a good job of modeling basic DDD concepts? Particularly intereste...

Can Persistence Ignorance Scale?

I've been having a brief look at NHibernate and Linq2Sql. I'm also intending to have a peek at Entity Framework. The question that gets raised, when I talk of these ORM's is "They can't scale", so can they? From Google I get the impression they're able to scale well, but ultimately I suppose there must be a price to pay, Is it worth pay...

Convention for Javascript Domain Model Objects

Hi all, If I have to create a domain model object in C# I might do something like this: public class Person { Public string Name { get; set; } Public string Gender { get; set; } Public int Age { get; set; } } In Javascript, what is the convention for defining such objects? I'm thinking something like this: NAMESPACE.Pers...

How to deal with a value object that needs to look up data in the database

I am just starting out with the study of domain driven design and it is quite possible that my understanding of the Entities/Values divide is faulty so if this is so please let me know. From my understanding, since its identity is completely defined by its properties an Address is the quintessential value object. From my understanding,...

Domain Driven Design and the role of the factory class

I'am unclear as to what the roles and responsibility of the factory class is. I know enough that the factory class should be resposible for the creation of domain objects (aggregate root) along with its associated entities and value objects. But what is not clear to me is where the factory "layer" lies with a DDD architecture? Should t...

Repository Pattern and Item Deletion when using SQL Backend

So lets say I have a class called Post that contains an IList I find that it's quite easy to cope with adding of Comments to the list when I ask my repository to update my post it can see which comments are new and send down to my data layer the required information, but what about when a comment is deleted? How do you handle this? Wo...

Where do all "bulk" operations belong in DDD?

In DDD one of the key concepts is Repository, which allows you to retrieve Entities (or Aggregate Roots) and then save them back after they are updated. Let assume that we need to perform some 'bulk' operation with entities, and the number of entities makes it absolutely impossible to retrieve them into memory. I.e. operation can only b...

how should i add an object into a collection maintained by aggregate root

lets say i have a BlogPost aggregate root. it holds a List<Comment>. how should the BlogPost AddComment signature look? is it OK to use: public void AddComment(Comment comment) { Comments.Add(comment); } or should i avoid creating references to root's children outside of it, and do something like this: public void AddCommen...

Using a non-English ubiquitous language?

While discussing specifications and functional requirements for a recent project, we were talking with the domain experts about accounting terms in Dutch since the whole team and the customers were all native Dutch speakers. When development started, we naturally implemented the domain classes and interfaces in English since we write al...

Transactions in the Repository Pattern

How do I encapsulate the saving of more than one entity in a transactional manner using the repository pattern? For example, what if I wanted to add an order and update the customer status based on that order creation, but only do so if the order completed successfully? Keep in mind that for this example, orders are not a collection in...

In NHibernate, can I use factory to build complex aggregate object (Entity)?

In NHibernate, can I use factory to build complex aggregate object (Entity)? If yes then how? If not.. then what is your approach? ...

Choosing between immutable objects and structs for value objects

How do you choose between implementing a value object (the canonical example being an address) as an immutable object or a struct? Are there performance, semantic or any other benefits of choosing one over the other? ...

What are the best practices when batch exporting from an application following DDD

Let say you hav a database with alot of products/customers/orders and the codebase (java/c#) contains all the business logic. During the night several batches are needed to export data to flat-files and then ftp them to properitary systems. how should we do this "write-database-into-a-flat-file? what are the best-practices? Some though...