Question

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 designed to be loosely coupled? Just getting my head around it, if someone can share his/her opinions it would be great.

Thanks

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top