Question

I have tried to find a solution to this naming problem, but I could not find a similar usage anywhere on the web. It could be either we have a design flow in the domain model, or we simply don't use the appropriate name for so called "ValueObjects".

Please read below..

We use Domain Driven Design with CQRS pattern. Below is how the domain model has been designed.

enter image description here

P.S Not related but for your information, our application uses ASP.NET MVC and the Controller comminicate withe the Service Layer. DTOs (Data Transfer Objects) are passed in/out to the MVC Controllers, which is not in the above diagram.

The problem is that we don’t use the "ValueObject" correctly. According Martin Fowler’s definition our ValueObjects are not a true representation of a ValueObject. http://martinfowler.com/bliki/ValueObject.html

For example our ValueObjects have an identity.

public class NoteValue 
{
    public int Id { get; set; }
    public string NoteName { get; set; }
    public string NoteNumber { get; set; }
    public DateTime NotExpiry { get; set; }
}

These ValueObjects simply carry data between the Commands, AggregateRoots and Domain Entities. For example AggregateRoot simply creates ValueObjects based on the Domain Entities, and return those ValueObjects to the Command Layer.

Below is not the complete implementation. Just a simple example to show the interaction

AggregateRoot extension method:

 private static IList<NoteValue> ToValueObject(this ICollection<Note> source)
 {
    var values = new List<NoteValue>();
    if (source != null)
         source.ForEach(i => values.Add(i.ToValueObject()));

    return values;
 }

AggregateRoot :

 Public IList<NoteValue> GetNotesValues()
 {
     return this._notes.ToValueObject();        
 }  

Command :

  var motesValues = notesAggregate.GetNotesValues();

We are struggling to find an appropriate name for these so called “ValueObjets”. They don't seem to be DTOs either and also we want to be able to differentiate from the DTOs that are used in the Services layer. Specifically we want to know an appropriate name that we can call for these types of objects (ValueObjects). Any thoughts greatly appreciated.

Was it helpful?

Solution

I don't know if this answers your questions but I might hopefully point you in the right direction.

There is a very good talk about Value Objects by Dan Berg Johnsson: http://www.viddler.com/v/6939b23

Also have a look at Vaughn Vernon's papers on Effective Aggregate Design: http://dddcommunity.org/library/vernon_2011

All in all DDD (especially when applying CQRS on the architectural level) takes some time to grasp. Be patient, read, learn, and join the DDD/Cqrs Google group

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top