domain-driven-design

Serializing business objects as JSON

I'm trying to serialize my business objects into JSON for consumption by a Javascript application. The problem is is that I'm trying to keep my business objects "pure" in the sense they are not aware of data access or persistence. It seems to me that "diluting" my objects with a toJSON() function would go against this goal. On the other ...

Should I strip FKs out of my domain model?

I'm starting a new project and plan on using nhibernate. I'm struggling with whether or not I should keep my domain model clean of persistence information by leaving out foreign keys. I keep feeling like some of my "model" isn't really necessary and that performance is going to be an issue. For example: In my db I have the following tab...

DDD and Client/Server apps

I was wondering if any of you had successfully implemented DDD in a Client/Server app and would like to share some experiences. We are currently working on a smart client in Flex and a backend in Java. On the server we have a service layer exposed to the client that offers CRUD operations amongst some other service methods. I understand...

Accessing entities via aggregate root: simple example?

Can you show simple example of accessing the contents of an entity in an aggregate via ita aggregate root? I am not clear on how you would represent the Aggregate permissions to reflect these concepts. tia. ...

Do you create the Aggregate Object when you instantiate a Root Entity?

Or do you define a new object that contains the Root Entity object among others? public class SomeAggregateName() { public EntityRoot root {get;set;} public Entity entity {get;set;} } OR Is this the Aggregate implied? public class EntityRoot() { public Entity entity {get;set;} } ...

Where does this functionality go?

Context: The structure of the code is that a WCF service (server-size) talks to a domain model, which talks to the data layer. I have a need that work assignments (for real people) need to be created when certain values change in an entity. Currently, I have placed that logic in the WCF service, but it makes me feel kind of icky. I ...

How to vet an Agile/TDD/DDD coach?

Although I am fairly comfortable (certainly not an expert) with TDD, DDD, and Agile concepts, I am working with some contractors who are not. They're smart guys though and given the limitations of our project they agree that techniques from these schools would increase our chances of success. We are not looking to go full blown but TDD...

How do you name 'back-reference' properties ?

I'm working on a project which has a rich domain-model. Some of my classes have collections of other types, and those other types have a property that refers back to their 'owner'. This sounds maybe a bit cryptic, so a code example would help: public class Product { private IList<ProductPrice> _prices = new List<ProductPrice>(); ...

DDD, related entities in master detail relationships

As I understand it all DDD entities should have an ID. So my question is in a master detail relationship, say a Product and a ProductDetail, should the ProductDetail have any knowledge of the Product? Is it necesarry with a ProductID property in the ProductDetail class? In a database this is of course normal as it is the only way to link...

Value equality comparisons on new objects

I've overridden Equals and GetHashCode in an abstract base class to implement value equality based on an object's key property. My main purpose is to be able to use the Contains method on collections instead of Find or FirstOrDefault to check if an instance has already been added to a collection. public abstract class Entity { publi...

DDD: What are good reasons for you to loosely-couple Entities?

Back in December, there was this post that was answered with "it is ok to use concret types [for simple object]". But I keep seeing more and more simple entities with interfaces in sample projects, and even the very large Enterprise application I just took control over (counting 89 interfaces and going). Is it that people are not picki...

DDD aggregates vs GoF's facade

Other than implementation details, are DDD aggregates similar to GoF's facade ? ...

DDD, NHibernate, and Project Structure / Naming

What do you recommend as the proper project structure for a WebForms solution that is utilizing NHibernate and trying to bring in some DDD concepts? Assuming the root namespace and solution name is Sample Sample.Domain - contains my domain objects and my mapping files Sample.Repositories - contains my repositories and nhibernate...

bidirectional relationship patterns with nhibernate

In my domain, an Employee and a Department have a one-to-many bidirectional relationship; to let the child Employee synchronize this, I have an 'internal' access field for the Set (Iesi for NHibernate) of Employees that are in the Department, which would otherwise be readonly public. Like so: Department class: protected internal ISet<E...

Returning a Domain Mapped List with LinqtoSql

How can I do this, ie keep the mapping separate? Instead of this: var people= (from p in db.people select new Person{ id=p.id, name=p.name }).ToList(); I want to do this: var people= (from p is...

best practices with code or lookup tables

[UPDATE] Chosen approach is below, as a response to this question Hi, I' ve been looking around in this subject but I can't really find what I'm looking for... With Code tables I mean: stuff like 'maritial status', gender, specific legal or social states... More specifically, these types have only set properties and the items are not...

DDD - Dependecies between domain model, services and repositories

Just wanted to know how others have layered their architecture. Say i have my layers as follows: Domain Layer --Product --ProductService (Should the imp go into this layer?) --IProductService --IProductRepository Infrastructure Layer --ProductRepository (Imp of IProductRepository in my domain) Now when a new product is created i have...

Accessing Aggregate Entities without Lazy Loading

I want to follow the DDD philosophy and not access entity objects of an aggregate directly. So, i have to call the root object to get the associated entity. But In other cases I dont always want every associated entity to load when the root is called. Is that the purpose of lazy loading? How do I access entity objects through the root...

DDD: Saving Changes to Model and accessing Repository

I have a Question object thats the root of the Question Aggregate. THe question has associated Answer Entities in its aggregate . When a new Answer object is created, the changes will be saved to DB via repository. Can I call a repository method SaveAnswer(Question ID) or must I call a SaveQuestion(QUestionID) and have the Repository det...

DDD: Organizing 100s of properties on an Entity

How would you organize an entity that has 100s of properties? One could go as far to say 100s of properties, with a few Value Objects (as a few of the properties have 2 or 3 properties of their own). But the point is, how to handle the large number of properties. I am re-creating our model from the ground-up using DDD, and the current...