• Keine Ergebnisse gefunden

Mediator Pattern Mediator Pattern

N/A
N/A
Protected

Academic year: 2022

Aktie "Mediator Pattern Mediator Pattern"

Copied!
13
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Mediator Pattern Mediator Pattern

a.k.a. Broker

a.k.a. Vermittler

(2)

Beschreibung

Hochschule Konstanz

g

l ifik i bj k b i h l

Klassifikation: Objektbasiertes Verhaltensmuster

Z k W i M Obj kt t i d

Zweck: Wenn eine Menge von Objekten untereinander 

kommunizieren wird eine Indirektion eingebaut d.h. die  Objekte reden nicht mehr direkt miteinander sondern  j indirekt über den „Mediator“ / „Vermittler“.

"Define an object that encapsulates how a set of objects  interact. Mediator promotes loose coupling by keeping 

objects from referring to each other explicitly and it lets you

objects from referring to each other explicitly, and it lets you 

vary their interaction independently." (Gamma et al., 1995)

(3)

Motivation

Hochschule Konstanz

Vorher:

Kollege

Kollege

ll Kollege

Kollege Kollege

(4)

Motivation

Hochschule Konstanz

Nachher:

Kollege

Kollege

Kollege Vermittler

Kollege

Kollege

(5)

Motivation / Beispiel

Hochschule Konstanz

p

Chat:

Viele Anwender (Collegues) unterhalten sich: ( g )

‐ Ungünstig alle untereinander zu verbinden M di t i t d Ch t

‐ Mediator ist der Chatroom

Fluglotsen: 

‐ Flugzeuge (Collegues) können sich nicht alle

‐ Flugzeuge (Collegues) können sich nicht alle 

untereinander verständigen Æ Kontrollcenter

(6)

Struktur

Hochschule Konstanz

(7)

Struktur

Hochschule Konstanz

Beispiel Flugverkehr:

(8)

Struktur

Hochschule Konstanz

Beispiel 

Flugverkehr:

(9)

Teilnehmer

Hochschule Konstanz

Mediator ‐ defines the interface for communication  between Colleague objects

Concrete Mediator ‐ implements the Mediator  interface and coordinates communication

interface and coordinates communication 

between Colleague objects. It is aware of all the  Colleagues and their purpose with regards to inter Colleagues and their purpose with regards to inter  communication.

Concrete Colleague communicates with other Concrete Colleague ‐ communicates with other 

Colleagues through its Mediator

(10)

Beschreibung II

Hochschule Konstanz

g

Abstrakte Vermittler / Interface

Abstrakte Mediatoren /Interfaces werden nicht Abstrakte Mediatoren /Interfaces werden nicht 

benötigt wenn nur ein Mediator verwendet wird. 

Sie werden benötigt wenn mehrere unterschiedliche 

Mediatoren zum Einsatz kommen.

(11)

Pro vs. Kontra

Hochschule Konstanz

P Pro:

‐ Einfacheres Verständnis der Logik im System da es an einer zentralen  Stelle gesammelt ist

‐ Lose Kopplung: Es können leicht neue Kollegen hinzugefügt, entfernt oder  geändert werden.

‐ Nur noch 1‐n Beziehungen statt m‐n. Nur noch 1 n Beziehungen statt m n. 

‐ Einfach erweiterbar: wenn neue Logik benötigt wird kann von dem  Mediator/Vermittler einfach vererbt werden

Kontra:

Kontra: 

‐ Bei vielen Teilnehmern kann es zu sehr kompliziertem Inhalt/Logik des  Mediators kommen Æ schwierig zu verstehen bzw. zu ändern

Si l i f f il d V i l fäll fäll d

‐ Single point of failure: wenn der Vermittler ausfällt, fällt das gesamte 

System aus

(12)

Verwandte Muster

Hochschule Konstanz

d

Facade Pattern

a simplified mediator becomes a facade pattern if the  mediator is the only active class and the colleagues are passive classes. A facade  pattern is just an implementation of the mediator pattern where mediator is the  only object triggering and invoking actions on passive colleague classes. The 

Facade is being called by some external classes.

Adapter Pattern

the mediator patter just "mediate" the requests

Adapter Pattern

the mediator patter just  mediate  the requests  between the colleague classes. It is not supposed to change the messages it  receives and sends; if it alters those messages then it is an Adapter pattern.

Observer Pattern

th b d di t i il tt

Observer Pattern

the observer and mediator are similar patterns,  solving the same problem. The main difference between them is the problem  they address. The observer pattern handles the communication between 

observers and subjects or subject It's very probable to have new observable observers and subjects or subject. It s very probable to have new observable  objects added. On the other side in the mediator pattern the mediator class is  the the most likely class to be inherited.

(13)

Danke für die Aufmerksamkeit!

Referenzen

ÄHNLICHE DOKUMENTE

“Back to the roots” is both an opportunity and challenge and it is in the long-term interests of everyone that dental implantology as a clinical method with a solid scientific

8: Autobahnwerkhof Bursins (Vaud),.. Auftraggeber: Stadt Zürich, Liegen- schaftenvervialtung. Vertreten durch das Amt für Hochbauten, Zürich Projekt:. Architektur: Adrian

The sites either known or thought to have had Decorated Mosaic tiles are listed in Table 14.1 and plotted in Figure 3.2 The counts of different types of Decorated Mosaic tiles given

5. (Inter)disciplinary studies Knowledge broker 6. Refine conceptual model Lead, facilitator 7. Quant system components Knowledge broker 8. (Final)

One of them is Gaurav Chaudhary, a 25­year old doctoral student of physics at the University of Texas at Austin,

[r]

Cytotoxic effect (mean ± standard error) of polyhexamethylen biguanid (PHMB), chlorhexidine (CH), hexamidine-diisethionat (HD), propamidin-isethionate (PD),

This finding is roughly consistent from our finding in this paper for bilateral Hungarian-Slovenian agri-food trade flows where high vertically differentiated products