domain-driven-design

IEnumerable<T>.ConvertAll & DDD

I have an interesting need for an extension method on the IEumerable interface - the same thing as List.ConvertAll. This has been covered before here and I found one solution here. What I don't like about that solution is he builds a List to hold the converted objects and then returns it. I suspect LINQ wasn't available when he wrote his...

Sharing domain objects between activities

I have written my application logic in domain objects (to enable multiple user interfaces and porting to other platforms), and am now lookng at implementing Activities for the user interface. Considering that each activity needs to serialise its state, what is the best way to ensure my domain objects are only serialised once? ...

How do I mock/fake: Many to many objects

Hello, So in my domain I have 3 objects. User, Item and Tag. Each user has items and tags, each item has tags and each tag has items. The objects look a little like this: public class User { public List<Item> Items { get; set; } public List<Tag> Tags { get; set; } } public class Item { public List<Tag> Tags { get; set; } ...

State Pattern with Memory

I was using State Pattern in a normal state machine. I wanted to be able to go from [A -> B], [B -> C], and [A -> C]. Now our domain has a new rule, now i need to go from [C -> A] also,but only if i have never been in B before. So we have states with memory. There are two possible solutions: Create a new State CB wich means C after B...

Architectures - Domain Driven Design vs strict business logic enforcement

My business objects are coded with the following architecture: validation of any incoming data throws an exception in the setter if it doesn't fit business logic. property can not be corrupt/inconsistent state unless the existing default/null is invalid business objects can only be created by the business module via a static factory ...

Mapping Validation Attributes From Domain Entity to DTO

Hi, I have a standard Domain Layer entity: public class Product { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set;} } which has some kind of validation attributes applied: public class Product { public int Id { get; set; } [NotEmpty, NotShorterThan10Characters, NotL...

Domain Driven Design, .NET and the Entity Framework

I'm new to domain driven design but want to learn it and use it for a new application. I will be using Entity Framework for data access. The basic layout so far is: ASP.NET MVC and other clients (mobile devices etc.) | Webservices | Domain Model (Services, Repositories, Aggregates, Entities and Value Objects) | Data Ac...

Authorization & User info in a Service Layer (.NET application)

Hello programmers, I am currently working with an enterprise application in a .NET environment (n-layered) and I would like to know the best way to manage authentication / authorization + data filtering in my BussinessLayer (BL). We will use that BL from several interfaces (ASP.NET applications and WebServices) and I think that my Servi...

Domain driven design and transactions in Spring environment

I used to design my application around anemic domain model, so I had many repository object, which were injected to the big, fat, transaction-aware service layer. This pattern is called Transaction script. It's not considered a good practice since it leads to the procedural code, so I wanted to move forward to the domain driven design. ...

How should the addition of an aggregate root to a repository be expressed?

Let's say we have an aggregate root entity of type Order that relates customers and order lines. When I think about an order entity it's more natural to conceptualize it as not being defined without an Id. An order without an Id seems to be better represented as an order request than an order. To add an order to a repository, I usuall...

Separation of concerns - DAO, DTO, and BO

So I have a DAO, DTO, and BO. The following code is the result: // Instantiate a new user repository. UserRepository rep = new UserRepository(); // Retrieve user by ID (returns DTO) and convert to business object. User user = rep.GetById(32).ToBusiness<User>(); // Perform business logic. user.ResetPassword(); user.OtherBusinessLogic(...

DDD - How to implement performant repositories for searching.

Hello, I have a question regarding DDD and the repository pattern. Say I have a Customer repository for the Customer aggregate root. The Get & Find methods return the fully populated aggregate, which includes objects like Address, etc. All good. But when the user is searching for a customer in the UI, I just require a 'summary' of the ...

NHibernate - Domain Driven Design - Business Rule Question

Hi all, I ve got an employee that holds several addresses in a collection. public class Employee { public string Name { get; set; } public AddressCollection Addresses { get; } } public class AddressCollection : IEnumerable<Address> { private readonly Employee employee; private IList<Address> items = new List<Address>...

How to handle injecting dependencies into rich domain models?

In a web server project with a rich domain model (application logic is in the model, not in the services) how do you handle injecting the dependencies into the model objects? What are your experiences? Do you use some form of AOP? Like Springs @Configurable annotation? Load time or build time weawing? Problems you encountered? Do you u...

DDD & UpdateOrder(IOrder order)

In my implementation I have a service layer to service my Aggregate roots. One of my aggregate roots is an order, to wich I have an OrderService. For reference, the project is Asp.Net MVC. On the update order page in the presentation layer a user can update their OrderLines. When the data is posted back to the server these are the acti...

Meaning of infrastructure & application code in domain-driven design

On the Domain-Driven Design website I see: Concentrate all the code related to the domain model in one layer and isolate it from the user interface, application, and infrastructure code. The domain objects, free of the responsibility of displaying themselves, storing themselves, managing application tasks, and so fort...

Domain Driven Design: How to access child of aggregate root

If I have an Order class an as aggregate root and 1000 line items. How do I load just one of the 1000 line items? As far as I understand, a line item can only be accessed through the Order class and has a "local" identity. Would I still create a repository method at the OrderRepository like "GetLineItemById"? Edit to comment the answer...

Interaction between unit of work and repository patterns

Hi, After reading thorugh plenty of articles I am still unsure about the responsibilities of Unit of Work pattern when interaction with repositories. Repositories are responsible for loading and saving Aggregate root entities, so consider the following example code: using(IUnitOfWork uow = container.CreateUnitOfWork()) { Reposito...

Aggregate roots. How far does the rabbit hole go.

I'm trying to use the Repository pattern for my current project and i'm currently in the process of trying to model the domain and find the aggregate roots. I've read of the 'Cascading Delete' rule which states that if it doesn't make sense to delete a member when the root is deleted then it shouldn't be part of the root. I'll use a P...

Tax calculation, Included & excluded, worldwide market...

I finishing the engine of my iPhone App, and need a flexible setup for tax handling. This is for LatinAmerica, USA & Europe markets. The App is a POS system. I support right now 2 taxes, and store the taxes in a table with Code, Name, Percent, FixedValue and if is included or excluded of the price. In this enough? Exist some sample or...