I. Adapter Mode
The adapter Mode means that an interface of a class cannot be accepted by the client and needs to be converted to another interface so that two mismatched interfaces can work together.
Class Structure:
Adaptee: source interface, which must be adapted <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Release/seq907/ao6yxqcK2s/bIpbXEvdO/release/aysrF5LPJxL + release + PHA + vtm49s/WyrXA/release + PHA + release/release + release/B97mry761xM + release/ serial + 1/a1pbbAysrF5KOszazKsb3hus + Serial + PHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20140401/20140401093103345.jpg" alt = "\"/>
Ii. Observer Mode
The observer mode is also called the publish-subscribe mode or the event listening mode. It defines one-to-many dependencies so that multiple observer objects can listen to one topic object at the same time, if the status of the topic object changes, all observer objects are notified.
Asynchronous messages (MQ and activeMQ) are based on this mode.
Class Structure:
Subject: The topic class. It stores all the observer objects in a List set and provides addition and deletion methods and notification methods after the status changes.
Observer: the abstract interface of the Observer, which provides an abstract action method. The specific business is implemented by sub-classes.
ConcreteObserver: a specific observer responsible for implementing business operations.
ConcreteSubject: a topic class that sends a notification to all registered observers when the internal status changes.
Advantages:
1) decoupling: Both Sides of coupling depend on abstract classes, rather than on specifics. So that their changes do not affect the changes on the other side.
2) The Observer uses an abstract class. The advantage is that it can extract the same code logic of multiple subclasses and put them in the abstract class.