domain-driven-design

How much logic should i put my repository methods when using repository pattern?

Hi, i'm struggling a bit with repositories. I'm using C# and NHibernate. The question i have is : how much should my repository do before it calls a save or a get? For example i have a user class which is an aggregate root. I want to call a method called "register" which will add the user and set some default values based on business ...

Domain Driven Design, Containing Entities and NHibernate Persistence

In my domain driven design I have a containing entity, say Car, which has a list of constituent entities, e.g. Wheel. Now, I want to add a ChangeWheel method to my car entity. Note that changing the wheel does not actually modify the car entity as such. It only affects one of the entites in its wheel collection. I.e. the Car entity h...

Domain Driven Design - Aggregate Roots

I'm struggling with aggregates and aggregate roots. I have a natural aggregate root which works for about 60% of the user requests. I.e. those requests naturally apply to the aggregate root. Within my aggregate I have another entity which can only exist as a member of the aggregate root. Users, however, will be told about this other ...

In DDD, are collection properties of entities allowed to have partial values?

In Domain Driven Design are collection properties of entities allowed to have partial values? For example, should properties such as Customer.Orders, Post.Comments, Graph.Vertices always contain all orders, comments, vertices or it is allowed to have today's orders, recent comments, orphaned vertices? Correspondingly, should Repositori...

How can I learn to REALLY design software?!

First off, my focus is web development (ASP.net webforms up to now), using C#. But, I am interested in learning design principles that will carry into any technology or language. I have been ready for a long time to step up, and learn how to design software the right way. Up to this point, the software I write has been designing the dat...

Based on DDD practices, where should this logic go and how do I avoid unnecessary dependencies?

I'm adding some logic to my web app to lookup geo-coordinates for a user, store them, then using those coordinates lookup the timezone and store that. My first go at this was to add a GeoCodeUser() method to a MappingService i had defined to do other map-related tasks. Because looking up the two bits of data relied on two different REST ...

Which parts of a Ruby DSL will I need to build by hand?

If I want to build a DSL in Ruby 1.9 or JRuby, will I need to do any of these stages by hand: Lexing Interpretation Parsing Just-in-time compilation Obviously, being a programmer, I don't like to write actual code as much as I can get away with, so I'm hoping none of these steps require manual labor :) ...

Where should I put a unique check in DDD?

I'm working on my first DDD project, and I think I understand the basic roles of entities, data access objects, and their relationship. I have a basic validation implementation that stores each validation rule with it's associated entity. This works fine for rules that apply to only the current entity, but falls apart when other data i...

Data Model design and Domain Model design

I'm attempting to model a grocery store. In the store, there are several "aisles". Each "aisle" has a group of "categories" of "items" it stores. Each "category" can only belong to one "aisle". Each "item" can only have one "category". The data model seems straight forward to me: An "aisle" table with an ID and DESCRIPTION A...

What Are The Major Questions/Solutions Encountered In Domain-Driven Design?

What questions/solutions arise when Domain-Driven Design is practised? I have found getting a grasp of it somewhat difficult as new situations keep arising, so I am trying to compile a list of good resources/questions in one place to assist me and anyone alike me having trouble grasping/implementing it. ...

Can I use this in Repository Model?

Hey everyone, I am working on a project using ASP.NET MVC, and repository model. I have repository classes, and services which consume these repository classes. My question is: Is it correct to return a IQueryable from my repository class and then use ".Where" and ".OrderBy" in a Service to generate a List? If yes, is it the best pract...

Does the DataMapper pattern break MVC?

I have been reading up on multiple PHP frameworks, especially the Zend Framework but I am getting confused about the proper way to go forward. Zend Framework does not use ActiveRecords but instead uses the Table Data Gateway and Row Data Gateway pattern, and uses a DataMapper to map the contents of the Row Data Gateway to the model, bec...

Dealing with an anemic domain model

I was trying to separate my DAL from my Business Layer, and in doing so, I decided to eschew any ActiveRecord approach and go for a DataMapper approach. In other words, my domain objects would not take care of persisting themselves. In doing so, I seem to be encroaching on the "anemic domain model" anti-pattern. For instance, one of the...

Entity, Value object or enum representation of objects within domain model

Hi, I'm trying to build a document management system and despite all the thigns i've read about entities, value objects, how to choose between how to map them etc... i still can't figure out what the "correct" way to do it is. Quite typically in such a scenerio, each document can beong belong to one or more categories, can be viewed by...

How to handle entity creation/editing in a master-detail

I'm wondering what strategies people are using to handle the creation and editing of an entity in a master-detail setup. (Our app is an internet-enabled desktop app.) Here's how we currently handle this: a form is created in a popup for the entity that needs to be edited, which we give a copy of the object. When the user clicks the "Can...

domain driven design with nhibernate and sql server

I have a reference application that I use to work through DDD issues, and my current focus is on persistence. An alternate title for this post could have been DDD / TDD persistence tools and methods, but that is a (very) broad topic and I do have a specific question on SQL Server. I'm going to outline my current tool set in this paragra...

How is Entity Programming changing the way we think about databases?

I am wondering how the shift from relational, table-based design to object-oriented, entity-based design is affecting the mindset of developers writing the next wave of applications. Given the nature of the debate swirling around the Entity Framework and Linq to SQL, is it premature to be thinking about entity-driven design? Are we bri...

Automatically Wrap a Controller Around a Service in ASP.NET MVC

Hi. The question title might not be clear but what I want to do is something like this: This is how I layer out my app App.Domain App.Services App.Web What I want is, if I request something like /api/OrderProcessor/GetAllOrder it will call method GetAllOrder in App.Services.OrderProcessorService. The method will return an IL...

Link two entities based on unique value not ID

I have the following database tables. Primary keys are ID and AnimalType.Type is a unique string. Animal - ID - Name - TypeID AnimalType - ID - Type [Herbivore, Carnivore] My classes are as follows. public class Animal { public int ID { get; private set; } public string Name { get; set; } public AnimalType Type { get;...

Looking for feedback on a use of the Adapter pattern.

In a project at work we have a certain value type class in our domain model that includes a very large number of attributes... public class BigValueType { private Foo foo; private Bar bar; private Baz baz; //... } We've realized that we would like to "focus" this into a number of different, somewhat more specialized c...