多层/多层系统等于紧耦合系统吗?
我发现每当我创建一个/多个层时,我都必须在一层到另一层之间进行转换,这是否意味着它是一个紧密耦合的系统?如果我要更改业务逻辑,删除数据库中的字段等,我是否必须更改从数据库层到客户端前端的所有层?
例如,一个Web服务公开一个“数据契约”对象,并将其转换为中间层的一些“业务对象”,然后将其转换为数据层中适当的“ORM对象”。而客户端调用Web服务,将数据契约转换为一些模型对象等等……
既然中间有这么多的转换,那么Web服务如何设计成松耦合呢?只是我的想法,如果有人可以分享他/她的意见那就太好了。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转换或映射与松散耦合是正交的,尽管有些相关。
的换句话说,松耦合与接口编程的概念相关,而不是与映射相关。
如果应用程序中的各层通过具体类型相互通信,则它是紧密耦合的。在这种情况下,分层并没有提供太多价值,您还不如构建一个整体应用程序。
另一方面,如果一个层通过接口与其他层通信,这些层将是松散耦合的,但通常仍然需要映射。
Translation or mapping is orthogonal, although somewhat related, to loose coupling.
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.