开发者

.NET Deployment of Interface/Classes for Command Pattern Question

In theory I would like to produce 2 projects:

1) Asp.net (Sever A)

2) DAL running (Server B)

I would 开发者_如何学编程like to utilise command objects to comunicate with the DAL.

ASP.net instantiates a command class e.g. CmdGetAllUsers which impliments IMyCommand interface and sends it to the DAL (using ASMX or WCF).

My question is:

Would the class definition of CmdGetAllUsers need to exist on the DAL server? Or would having the interface definition be enough?

My goal is to reduce the need to redeploy the DAL code, and have it as a fairly simple pass-through layer.

Many thanks for your time.


To answer your question, no, the interface definition is not enough. It needs to have the concrete implementation because that's where the code to implement the methods lives. No code for the implementation, no execution.

On a larger note, why not just implement the methods in the service layer directly? Instead of passing a command back to your data layer to execute, have the service layer implement the method as a "command". Your DAL will be more conventional, but that's a good thing I think. Instead of scattering your DB code throughout all of the various Command class implementations, you'll have it localized in the DAL. You'll also have a central location (the service) to do any business-related rule-enforcement.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜