开发者

Multi Tiers / Multi Layers system equals to a tightly coupled system?

开发者 https://www.devze.com 2022-12-15 16:39 出处:网络
I find that whenever I create a layer/tier, I have to translate between one layer to the other, does that mean it is a tightly coupled system?If I was to change a business logic, remove a field in the

I find that whenever I create a layer/tier, I have to translate between one layer to the other, does that mean it is a tightly coupled system? If I was to change a business logic, remove a field in the database, etc, I would have to change ALL layers from the database layer to the client front end?

E.g. A web service that exposes a "data contract" object, and converts it to some "business objects" in the middle layer, then converts it to the appropriate "ORM object" in the data layer. And the client calling the web service, converts the datacontract to some model objects, etc...

Since there are so many translations in between, how can web services be designe开发者_运维百科d to be loosely coupled? Just getting my head around it, if someone can share his/her opinions it would be great.

Thanks


Translation or mapping is orthogonal, although somewhat related, to loose coupling.

  • If you map from concrete type to concrete type the mapping is tightly coupled
  • If you map from abstract type to concrete type or the other way around, the mapping is loosely coupled

In other words, loose coupling is related to the concept of programming to interfaces - not to mapping.

If layers in an application communicate with each other through concrete types, it's tightly coupled. In such a case, layering doesn't provide much value, and you might as well have built a monolithic application.

On the other hand, if a layer communicates with other layers through interfaces the layers will be loosely coupled, but mapping is often still required.

0

精彩评论

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