Mediator Matt G Ellis Overview Intent Motivation Mediators
- Slides: 24
Mediator Matt G. Ellis
Overview ► Intent ► Motivation ► Mediators in GUI applications ► Mediators and Relational Integrity ► Conclusion ► Questions
Intent ► 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 very their interaction independently
Motivation ► Object Oriented design encourages distribution of behavior among objects ► However, Good design is thwarted by every object referencing every other object ► Changing systems behavior becomes difficult ► Helps to prevent classes from becoming “thick”
Mediator versus Façade ► Façade pattern help refractor Flight. Panel from Oozinoz ► Refactoring can only go so far, complex applications still might need complex code even after applying Façade pattern
Mediators at Oozinoz ► Chemicals for fireworks kept in tubs ► Robots move most of the tubs from machine to machine ► However, humans can override the system
Flight. Panel_1 ► Many methods exist to lazy-initialize variables ► Rest control event handling logic
Challenge 1 ► Refactor Place. ATub_1 into two classes, introducing a new Place. ATub. Mediator that receives the events of the GUI
Challenge 1 ► Refactor Place. ATub_1 into two classes, introducing a new Place. ATub. Mediator that receives the events of the GUI
Relational Integrity ► If Object A points to Object B then… ► Object B points to Object A ► A more rigorous definition can be found in Metsker, page 108
Relational Integrity and Java ► Two Major Problems § Objects forget previous values § No built in support for Relational Integrity Tub Machine T 305 Star. Press-2402 T 308 Star. Press-2402 T 377 Shell. Assembler-2301 T 379 Shell. Assembler-2301 T 389 Shell. Assembler-2301 T 001 Fuser-2102 T 002 Fuser-2102
Model Tub Machine T 305 Star. Press-2402 T 308 Star. Press-2402 T 377 Shell. Assembler-2301 T 379 Shell. Assembler-2301 T 389 Shell. Assembler-2301 T 001 Fuser-2102 T 002 Fuser-2102
Challenge 2 ► Suppose we have this code: //tell tub about machine, and machine about tub t. set. Machine(m); m. add. Tub(t); ► What happens when t is tub T 308 and m is Fuser-2101?
Challenge 2
Challenge 2
Challenge 2
Challenge 2 ► Really Bad Things… ► Two machines think they have tub T 308 in them ► This can’t happen in the real world, why should it happen at Oozinoz? ► Mediators can help
Mediators for Relational Integrity ► Pull all relational information into a mediator outside both classes ► Have both tubs and machines have a reference to this mediator ► Use a Map to store these key/value pairs
Mediators for Relational Integrity ► get. Machine is simple, since t is the key of the map, Hash. Map makes it easy to get the value.
Mediators for Relational Integrity ► Somewhat same. more complex, but the intent is the
Mediators for Relational Integrity ► The most trivial method of all. Relational Integrity is maintained by the internal structure of the Map
Challenge 3 ► Write the code for the Tub methods: get. Machine() and set. Machine()
Conclusions ► Mediators provide loose coupling creating a “pluggable” system § Changing a mediator can change how applications deal with events ► Mediators often found in GUIs § Swing’s event framework nudges the use of mediators, but they can be in the same class ► Mediators also help to provide relational integrity between objects
Questions
- Implicit intent android studio
- Chemical mediators of inflammation
- Metabolic response to injury
- Mediators of inflammation
- Peer mediators definition
- Pa council of mediators
- Mediators of inflammation
- Motivation to learn an overview of contemporary theories
- Yang hu lancaster
- Courtney bass mediator
- Mediator vs intercessor
- Mediator vs moderator
- Mediator c++
- Keterampilan dan teknik mediator
- Pengakuan pbb terhadap kemerdekaan indonesia
- Mediator wzorzec
- Stephen ruttle mediator
- Jesus the mediator
- Lynn cohn mediator
- Jesus is our mediator hebrews
- Mii mediation
- Mediator psychology
- The mediator poem
- Rmer
- Mediating vs moderating variable