domain-driven-design

Paging in NHibernate

Lets say I have a domain model with a class called Blog that has a property called BlogEntries (that contains objects of type BlogEntry). If I have a database model with two tables "Blog" and "BlogEntry", it's not impossible that I have 1000 blog entries for a blog. If I were to show the blog on a web site, I would only want to display m...

Ubiquitous language - term for developers and users

Our project's team members are a big fans of Ubiquitous Language concept from the Domain-Driven Design Community. And here is the problem we've found: Non-techy users like to use a simplified names of all the concepts, they don't want to know all the details, and that's OK. But we can't do the same in code, because this concepts aren't...

When using Aggregate objects do you use custom collections for the associations or not ?

For example is it better to have: public class Case : EntityIdentifiable { public Jobs Jobs { get; set; } public Vehicles Vehicles { get; set; } public Locations Locations {get;set;} public IDistances Distances { get; set; } } or public class Case : EntityIdentifiable { public Dictionary<string,Job> { get; set; ...

How do restrict access to a class property to only within the same namespace

How do restrict access to a class property to within the same namespace? Consider the following class. The Content class cannot Publish itself, instead the ContentService class will do a few things before changing the state to published. public class Content : Entity, IContent { public string Introduction { get; set; } ...

ASP.NET MVC: where to keep entity being edited by user

Here's a simple problem: users want to edit products in grid-like manner: select and click add, select and click add... and they see updated products list... then click "Finish" and order should be saved. However, each "Add" have to go to server, because it involves server-side validation. Moreover, the validation is inside domain entit...

ASP.NET MVC models when using external web services

I'm getting started on a new MVC project where there are some peculiar rules and a little bit of strangeness, and it has me puzzled. Specifically, I have access to a database containing all of my data, but it has to be handled entirely through an external web service. Don't ask me why, I don't understand the reasons. That's just how it i...

Handling data content security

So let's say that in your application you have to handle data content security, in such a way that application defines several "Entities" that have to be secured so that user cannot view, edit etc. certain code ranges. Let's say we have secured entities such as Location, Department, Division, ProductLine etc. and each user gets associat...

Domain Driven Design - Repositories and aggregate roots

I have a domain model that contains a forum. I have forum, thread and post entities. The forum is a standalone entity. Ie it does not contain thread as part of an aggregate. This is because threads are not owned by a particular forum (you can move a thread to a different forum). I don't know if I should model posts as part of a threa...

Multiple Service Layers and Database Transactions

I'm just wondering how to best handle transactions across multiple service layers. The service layers use an ORM to store and retrieve from the database. Should the transactions be known and handled within the individual service layers? Or should they be handled by another layer? For example: I have two service layers for users and clie...

How to solve state-stateless in a client-server application?

I've read some books on creating stateless websites, I've read some about stateful client applications, but a lot of complexity comes along when you have to combine both. We have a Flex application that needs to persist data to a database via .NET services. Things to keep in mind are: - Concurrency (optimistic/pessimistic) - Performance:...

Design Aggregate Root Properly

I have some problems designing the aggregate root. Here is how I see it in my mind :) Store (the aggregate root) -> Sales - A store create a sale every day -> Zones - A store is divided into zones -> Styles - A zone has x number of styles --> Colors - A style has x number of colors etc.. Now based on this my aggregate ...

repository pattern with a legacy database and Linq to SQL

I'm building an application on top of a legacy database (which I cannot change). I'm using Linq to SQL for the data access, which means I have a (Linq to SQL) class for each table. My domain model does not match with the database. For example, there are two tables named Users and Employees, and therefore I have two Linq to SQL classes n...

C# Advanced XML Serializer that doesn't require domain object pollution

Are there any closed or open source projects for a XML serializer for C# that can serialize for the most part any object without the need to pollute my domain objects with tons of attributes? That will also handle serialization of collections built with the internal generics classes? A bonus would be that it can handle serializing an int...

Design Patterns: Factory and Repository

Hello, I have been wondering if the Factory Pattern and the Repository Pattern is keened to go hand in hand in a Domain Driven Design project? The reason i ask is the way i'm doing this is like so: GUI -> ClassFactory -> ClassProduct (is in the Domain Model) -> ClassProductRepository -> Datasource The GUI calls the ClassFactory to se...

Should a Repository be responsible for "flattening" a domain?

Disclaimer: I'm pretty new to DDD and its associated terminology, so if i'm mislabeling any concepts, please correct me. I'm currently working on a site with a relatively simple domain model (Catalog items, each of which stores a collection of CatalogImage items.) My repository follows the standard interface of FindbyID(int ID) GetA...

Tags mapping in NHiberbate

When I'm asking this question on stackoverflow, I can add tags to it. So, in DDD, I would have a class Question that somehow has tags. One way to model it would be with a List of tags, since a tag is not really an entity (or is it?). public class Question { // ... public List<string> Tags; } In the database, however, I would ...

Is there a rich domain model example?

I'm looking for a simple example to illustrate the benefits of using a rich domain model. Ideally, I'd like a before and after code listing (which should be as short as possible). The before code listing should show the problem being solved using an anemic domain model, and a lot of fairly procedural service-layer code, and the after co...

Entity Framework POCO Does Not Fit Nicely with Domain Objects

I have taken a model first approach for a project i'm working on. An example of a class relationship is shown as follows, pretty strightforward: public class Product { public int Id { get; set; } public string Name { get; set; } List<Photo> Photos { get; set; } } public class Photo { public int Id { get; set; } public string...

DDD Repositories pattern with NHibernate

Hi Im confused. This is a blog entry of Ayende Rahien Repository is the new singleton. I believe that a repository should only do CRUD operations and not addtional queries otherwise youll end up with methods like these on your repository. FindCustomer(id) FindCustomerWithAddresses(id) FindCustomerWith.. So my question is, where(in ...

How many levels of abstraction do I need in the data persistence layer?

I'm writing an application using DDD techniques. This is my first attempt at a DDD project. It is also my first greenfield project and I am the sole developer. I've fleshed out the domain model and User interface. Now I'm starting on the persistence layer. I start with a unit test, as usual. [Test] public void ShouldAddEmployerToCollect...