Eric Van der Vlist, author of XML Schema: The W3C's Object-Oriented Descriptions for XML (O'Reilly, 2002), describes the differences between the two types of coupling with this analogy: In a tightly coupled system, you have direct control over the operation. For example, flipping a wall switch to turn on a light is a tightly coupled system. However, making a telephone call to order a book is a loosely coupled system. It could be tightly coupled only if you had access to the button controlling the printer that will print the book you order.
Tightly coupled systems are usually fast and safe, and the risk of transmission errors is very low. Loosely coupled systems, on the other hand, are usually more error-prone but also more flexible. The clerk you talk to on the phone may misunderstand the ISBN number of the book you want to order or make an error while entering it. But if you don't remember the ISBN number, you can still tell the clerk that you want the latest book on the World Wide Web Consortium's XML schema by a guy with a Dutch name from a publisher that puts pictures of animals on its book covers—and when you do that, you've got a good chance of being understood.
Tight coupling tends to make component maintenance and reuse much more difficult, because a change in one component automatically means changes in others. Similarly, tight coupling makes extra work when an application has to adapt to changing business requirements, because each modification to one application may force developers to make changes in other connected applications.
In general terms, a Web service is a type of SOA in which interfaces are based on standardized Internet protocols. In addition, except for binary data attachment, Web service messages must be in XML. Generally speaking, a Web service is little more than an SOA that uses Simple Object Access Protocol and the Web Services Description Language. However, an SOA doesn't require the use of Web services as we understand them, and some types of Web services can be deployed without an SOA. (The End)
松散耦合与紧密耦合
SOA的一项关键特性就是使用松散耦合连接。传统上,应用程序与应用程序之间或者应用程序与服务之间的连接是紧耦合的,如用CORBA(公共对象请求代理体系结构)那样。此差异是很重要的。
《 XML Schema: The W3C's Object-oriented Descriptions for XML》一书(O'Reilly公司2002年出版) 的作者 Eric Van der Vlist有下列比喻来描述这两类耦合之间的差异:在紧耦合系统中,你直接控制操作。例如,扳动墙上的开关接通电灯就是紧耦合系统,而利用电话订购书就是松耦合系统。只有当你访问控制打印机(该打印机将打印你订购的书籍)的按钮时,才可能是紧耦合。
紧耦合系统通常比较快、也安全,传输误差的风险非常低。另一方面,松散耦合系统通常比较容易出错,但比较灵活。当你在电话上通话时对方职员可能会听错你要订购书的 ISBN编号、或者在输入时出错。如果你不记得ISBN编号,你还可以告诉对方职员,你要一本由一名有荷兰名字的人写的有关3W联盟的XML范式的新书,该书的出版社通常将动物的图片放在书的封面上,当你这样做时,你就得到了被理解的好机会。
紧耦合往往会使部件的维护和重复使用变得非常困难,因为一个部件中的修改就自动意味着其他部件中的修改。同理,在应用程序不得不适应变化了的业务要求时,紧耦合就要做额外的工作,因为一个应用程序中的一次修改将迫使开发人员对其他相连接的应用程序进行修改。
从一般意义上讲, Web Services 就是一类 SOA ,其接口都是基于标准化了的互联网协议。此外,除二进制数据附件, Web Services 消息必须用 XML语言。通常讲, Web Service 只是一个用了 SOAP (简单对象访问协议)和 Web Services 描述语言的 SOA 。但是, SOA 不要求使用我们所理解的 Web Services ,有些类型的 Web Services 不用 SOA 也能部署。
文章评论(0条评论)
登录后参与讨论