There is a client-service application that uses WCF to build service-oriented architecture and DDD to build domain layer inside the service.
In the Domain Layer there is a domain object Customer
with methods:
- to change Phone and Address
Customer.Relocate(Phone, Address)
- to assign Sales Manager to a Customer
Customer.Assign(SalesManager)
- to make Discount to a Customer
Customer.Make(Discount)
Since this Domain Layer is used inside a WCF Service, CustomerService
is created with service methods:
CustomerService.Relocate(CustomerID, PhoneDTO, AddressDTO)
CustomerService.Assign(CustomerID, SalesManagerID)
CustomerService.MakeDiscount(DiscountDTO)
These methods validate parameters, request domain objects and invoke domain object methods to apply business logic.
The problem is that it looks like huge code duplication, since WCF Service methods are almost (90%) identical to methods of domain layer with parameters, expressed in IDs and DTOs.
- Is this method duplication always happening when WCF / SOA is used with DDD?
- Is there any way to make this thin WCF Service layer build automatically from Domain Layer?
- Any other ideas?