--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
|
Muhammad Bilal
Senior Software Engineer (.NET),
Aurora Solutions
|
--
I am currently using a DTOs with read-only attributes to expose state of the domain objects when needed. Plus when the new code has to interact with existing code, I allow getters on those attributes that are needed so that we don't change existing/legacy code. The product does not use any ORMs. I have tried explaining to people not to use getters arbitrarily, few listen to that, few don't, but when working under tight schedules, they always fall back on getters. The only thing I am aiming for, is to ensure the domain logic stays inside the domain objects, instead of being scattered around in other places.-Arun
public class Basket{private Basket(BasketSnapshot snapshot){Items = CreateBasketItemsFrom(snapshot.ItemsSnapshot);DeliveryCost = snapshot.DeliveryCost;}// ...
public BasketSnapshot GetSnapshot(){
var snapshot = new BasketSnapshot();snapshot.ItemsSnapshot = CreateItemSnapshotFrom(Items);snapshot.DeliveryCost = this.DeliveryCost;return snapshot;
}public static void CreateBasketFrom(BasketSnapshot snapshot){
return new Basket(snapshot);
}
public class BasketRepository : BasketRepository{// ....
public Basket FindBy(Guid id){
Basket basket;BasketDataModelbasketDataModel = FindDataModelBy(id);if (basketDataModel != null){
var basketSnapshot = ConvertToBasketSnshot(basketDataModel);basket = Basket.CreateBasketFrom(basketSnapshot);
}return basket;