开发者

What is the difference between a DDD service and a WCF service?

开发者 https://www.devze.com 2023-02-01 00:33 出处:网络
I have a DDD class library. In it, I have the following structure: > Core > - DataAccess ( my LINQ repositories)

I have a DDD class library. In it, I have the following structure:

> Core
> - DataAccess ( my LINQ repositories)
> - Domain ( my data objects)
> - Impl (my services)

I have recently added a WCF project to my solution. This project will be exposing JSON web methods to an iPhone client. The WCF methods are not too sophisticated - GetCustomers / GetCustomerDetails / GetAlerts GetAlertDetails / GetProblems / GetProblemDetails / GetInventory / GetInventoryDetails, GetDataPoints / GetDataPointDetails / etc...

What I am noticing is that most of the methods in WCF are exposed by my services layer in my DDD model. So, I am finding myself doing a lot of code like this:

public List<Alert> GetAlerts()
{
    AlertSerice _as = new AlertService;
    List<Alert> alerts = _as.GetAlerts();

    return alerts;
}

This doesn't feel right to me. I am wondering if I should be doing away with my Impl folder (with all the DDD services) and recompile. Then, add the DLL as a refcerence in my WCF project and code my previous DDD services as WCF met开发者_Python百科hods?

Does WCF really just need the Domain and DataAccess layers?

Thanks in advance.


AlertSerice _as = new AlertService;
List<Alert> alerts = _as.GetAlerts();

It seems possible you may be using Domain Services incorrectly.

In DDD, Domain Services are used when multiple aggregate roots must be involved in an operation.

GetAlerts would appear to be functionality that clearly belongs in an AlertRepository (and not just belongs, but is the core functionality of that Repository).

As for WCF Services, they are a public endpoint. Their job is to receive requests from a client and carry out commands on the domain or queries. The focus in this sort of service is usually translation - from primitive typed input parameters to DTO's for output.


From an architectural perspective using a distinct service layer to expose your data allows a level of abstraction, and isolation for protected and internal methods, you can simply plug in a different service handler (Service configuration) to expose the data in a binary or XML format. Where you need to spend your time is ensuring the levels of abstraction are clearly defined and ensure code access rules and security between layers exposed to the service layer are implemented.

0

精彩评论

暂无评论...
验证码 换一张
取 消