开发者

Name collisions between layers

So I'm developing a very cool (and very large) n-tier application.

Basically I have the following assemblies:

Domain

Domain.Contracts

Services

Services.Contracts

Presentation.Admin

Presentation.Web

Presentation.Core (shared between Admin & Web)

I may implement Presentation.Core.Contracts

My main issue I'm wrestling with are name collisions between the different layers. Ie.

Services.Contracts.AccountServicesRequest

Domain.Contracts.AccountServicesRequest

I had the same issue with Service names (in this case I am just using classes as services rather than WCF, etc). Ie:

Services.Contracts.IAccountService

Domain.Contracts.IAccountService

I resolved this by now making all "service handlers" in the domain layer IxxxServiceHandler which gives me this:

Services.Contracts.IAccountService

Domain.Contracts.IAccountServiceHandler

However, I haven't been able to resolv开发者_如何学运维e this issue with the objects that are passed back and forth between layers. This seems to be sprinkled in a bunch of places through my solution(s). I was just curious to see if anyone has had the same issues. If so, how did you resolve them?


Yes, I have run into this problem, but I have fixed it soon enough every time.

A good class naming convention can help. Avoid using the same name in classes across multiple layers.

Alternatively, you can use namespace aliases, so that you would be using, for example:

services::IAccountService
domain::IAccountService

Does this help?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜