domain-driven-design

nhibernate mapping Ilist with composite-element.

I have been trying to work with DDD style for my e-commerce application. Most of my business logic are implemented using fake repositories. Now, I would like to use NHibernate to hook my Domain Model to a real database. I have a class Order which contains a list of OrderLines object public IList<OrderLine> OrderLines{ ... } //line 1 ...

My Domain objects are not modifiable; can I use NHibernate effectively with them?

I'm attempting to work with a legacy system which already has well-defined domain objects. I would like to use NHibernate as the ORM for some of these objects, but since I cannot modify the objects to allow their methods to be overridden by NHibernate, normal techniques for lazy-loaded objects wont be viable. Are there any alternative a...

Questions regarding Domain driven Design

Hi All, After reading Eriv Evan's Domain driven design also i have few doubts. I searched but no where i could able to find satisfying answers. Please let me know if anyone of you have clear understanding below questions. My concerns are Repository is for getting already existing aggregates from DB,Web service . If yes, Can Reposit...

DDD: aggregate root question

Let's say i got 2 entities - Foo and Bar. Foo is an aggregate root and contains Bar. As far as i understand, it should look like this: public class Foo{ private readonly Bar Bar; } I want to provide functionality for users to choose Bars for Foos from a defined list (and change it). If repositories are supposed to be for aggreg...

Getting started with TDD and DDD

I've just finished reading "Domain-driven design: tackling complexity in the heart of software" by Eric Evans and I'm attempting to write my first domain-centric application (in C#). The application will be used by our helpdesk to track the allocation of computers to users. I've sketched a simple class diagram to reflect part of the do...

How to implement CQS with in memory changes?

Having Watched this video by Greg Yound on DDD http://www.infoq.com/interviews/greg-young-ddd I was wondering how you could implement Command-Query Separation (CQS) with DDD when you have in memory changes? With CQS you have two repositories, one for commands, one for queries. As well as two object groups, command objects and query o...

asp.net MVC:hierarchical domain model and controllers

My domain model is this: we have a bunch of schools as the root of the "hierarchy". Each school has teachers and courses, and each course has one teacher. I am trying to model this with the logic of the mvc framework and I 'm quite confused. For example, the \school\details\x should give the first page of a school. That should contain a ...

Domain Modelling Help - Product and Suppliers

I have this domain model (simplified), that represents a product that has a basic price and attached has numerous suppliers that provide a specific discount percentage against the basic price: public class CarDerivative { public string Name { get; set; } e.g. StackOverflow Supercar 3.0L Petrol public double BasicPrice { get; set...

How to avoid anemic domain models, or when to move methods from the entities into services

I have a common scenario that I am looking for some guidance from people more experienced with DDD and Domain Modeling in general. Say I start out building a blog engine, and the first requirement is that after an Article is posted, users can start posting Comments on it. This starts fine, and leads to the following design: public clas...

Should persistence be the responsiblity of a domain object? (Can you comment on this article?)

I read an article. In the source code, Entity objects are doing all the CRUD operations. This means Entity objects are calling the Repository directly from the methods. The comments indicate: Persistence is absolutely the resposibility of a domain object Is this correct? ...

Design: When the line between domain objects and service objects isn't clear

This question is, at it's core, a design question. I'll use a Java/JEE example to illustrate the question. Consider a web-mail application which is built using JPA for persistence and EJB for the services layer. Let's say we have a service method in our EJB like this: public void incomingMail(String destination, Message message) { ...

Domain Driven Design: When to make an Aggregate Root?

I'm attempting to implement DDD for the first time with a ASP.NET MVC project and I'm struggling with a few things. I have 2 related entities, a Company and a Supplier. My initial thought was that Company was an aggregate root and that Supplier was a value object for Company. So I have a Repository for company and none for Supplier. Bu...

Nhibernate/Domain Objects generate test objects with random data from factory

We are doing some DDD at work and I am trying to find a good utility for generating Domain Objects with random data, or predefined data, and populating dependent objects. Example Usage: var user = DDDObjectFactory.CreateUser(); user.Name = "TestUser"; In our world, a user can not exist without a organization, so if there is no organi...

BDD/DDD Where to put specifications for basic entity validation?

Alternatively, is basic entity validation considered a specification(s)? In general, is it better to keep basic entity validation (name cannot be null or empty, date must be greater than xxx) in the actual entity, or outside of it in a specification? If in a specification, what would that look like? Would you have a spec for each fiel...

Fluent NHibernate HasMany Collection Problems

Update: It appears that changing my mapping from Cascade.All() to Cascade.AllDeleteOrphan() fixes most of my issues. I still have to explicitly set the Company property on the OperatingState, which seems unnecessary as it's being added to the Company entity, but at least I can work with that during an update. I still need to test that wi...

Is it possible to use NHibernate without altering a DDD model that is part of a framework

I dig a lot of things about the DDD approach (Ubiquitous language, Aggregates, Repositories, etc.) and I think that, contrary to what I read a lot, entities should have behavior rather then being agnostic. All examples I see tend to present entities with virtual automatic properties and an empty constructor (protected or worst, public) a...

DDD Repositories and Factories

i've read a blog about DDD from Matt Petters and according and there it is said that we create a repository (interface) for each entity and after that we create a RepositoryFactory that is going to give instances (declared as interfaces) of repositories is this how project are done using DDD ? i mean, i saw projects that i thought tha...

How To Implement The Query Side Of CQS in DDD?

I have implemented the command side of DDD using the domain model and repositories, but how do I implement the query side? Do I create an entirely new domain model for the UI, and where is this kept in the project structure...in the domain layer, the UI layer, etc? Also, what do I use as my querying mechanism, do I create new repositor...

Select n+1 problem

Foo has Title. Bar references Foo. I have a collection with Bars. I need a collection with Foo.Title. If i have 10 bars in collection, i'll call db 10 times. bars.Select(x=>x.Foo.Title) At the moment this (using NHibernate Linq and i don't want to drop it) retrieves Bar collection. var q = from b in Session.Linq<Bar>() ...

What are some large, model-rich open source applications?

I need to identify a large model-rich open source ruby, c-sharp, objective-j or java applications so that I can target them for a series of projects. Are you guys aware of any that I could use? ...