SlideShare a Scribd company logo
Motivations

 lots of classes in the design of framework
 If certain principles are not applied the final
  framework will end in a total mess
 to avoid tight coupled frameworks, we need a
  mechanism to facilitate the interaction between
  objects in a manner in that objects are not aware of the
  existence of other objects.
Mediator


  Mediator promotes loose coupling by keeping objects
 from referring to each other explicitly
Intent

 Define an object that encapsulates how a set of objects
  interact.
 Design an intermediary to decouple many peers
 Promote the many-to-many relationships between
  interacting peers to “full object status”.
Unmediated
Mediated
Mediator
Check list

 Identify a collection of interacting objects that would
  benefit from mutual decoupling.
 Encapsulate those interactions in the abstraction of a
  new class.
 Create an instance of that new class and rework all
  “peer” objects to interact with the Mediator only.
 Balance the principle of decoupling with the principle
  of distributing responsibility evenly.
 Be careful not to create a “controller” or “god” object.
Mediator design example


 Let us consider design of a class in which one object
 send messages to other objects by means of if then if
 condition explicitly
public class WorkerObject
   {
      private string _message;

        public WorkerObject(string message)
        {
          _message = message;
        }

        public string Message
        {
          get{return _message;}
          set{_message = value;}
        }

        public SendMessage(string message)
        {
          Console.WriteLine(quot;Message sent : quot; + message);
        }
    }
WorkerObject senderObject = new WorkerObject(quot;message0quot;);
WorkerObject workerObject1 = new WorkerObject(quot;message1quot;);
WorkerObject workerObject2 = new WorkerObject(quot;message2quot;);
WorkerObject workerObject3 = new WorkerObject(quot;message3quot;);
if(!workerObject1.Message.Equals(senderObject.Message))
{
   workerObject1.SendMessage(senderObject.Message);
}
if(!workerObject2.Message.Equals(senderObject.Message))
{
   workerObject2.SendMessage(senderObject.Message);
}
if(!workerObject3.Message.Equals(senderObject.Message))
{
   workerObject3.SendMessage(senderObject.Message);
}
Mediator
 we create a mediator class, DoSomeMediation.
 This class contains two methods Register and
  SendMessage
 The Register method catalogs all the classes we want
  to mediate between.
 The SendMessage method is where the functional
  code actually exists
public class DoSomeMediation
   {
         private static ArrayList _workerObjects = new ArrayList();

            public static int Register(WorkerObject workerObject)
        {
                    return _workerObjects.Add(workerObject);
            }
            public static void SendMessage(WorkerObject senderObject)
            {
              if(senderObject == null) return;
              string messageToSend = senderObject.Message;

                    foreach(WorkerObject workerObject in _workerObjects)
                    {
                        //send message to all other objects registered
                                   if(!workerObject.Message.Equals(senderObject.Message))
                                        workerObject.SendMessage(messageToSend);
                }
            }
    }
WorkerObject senderObject = new WorkerObject(quot;message0quot;);
WorkerObject workerObject1 = new WorkerObject(quot;message1quot;);
WorkerObject workerObject2 = new WorkerObject(quot;message2quot;);
WorkerObject workerObject3 = new WorkerObject(quot;message3quot;);
DoSomeMediation.Register(senderObject);
DoSomeMediation.Register(workerObject1);
DoSomeMediation.Register(workerObject2);
DoSomeMediation.Register(workerObject3);
DoSomeMediation.SendMessage(senderObject);
Flow diagram
                        WorkerObj1




             Mediator
 SenderObj




                           Worker
                            Obj2
CCS Model

 SenderObject(reg,sendmedmsg,sendobjmsg,printmsg)=
  reg.sendmedmsg’.SenderObject<reg,sendmedmsg,sendobjmsg,printms
  g>

 Mediator(sendmedmsg,sendobj1msg,sendobj2msg)=
  sendmedmsg.sendobj1msg’.Mediator<sendmedmsg,sendobj1msg,sendo
  bj2msg> +
  sendmedmsg.sendobj2msg’.Mediator<sendmedmsg,sendobj1msg,send
  obj2msg>
 Workerobj1(reg,sendmedmsg,sendobjmsg,printmsg)=sendobjmsg.prin
  tmsg’.Workerobj1<reg,sendmedmsg,sendobjmsg,printmsg>
 Workerobj2(reg,sendmedmsg,sendobjmsg,printmsg)=sendobjmsg.prin
  tmsg’.Workerobj2<reg,sendmedmsg,sendobjmsg,printmsg>
Simulation on MWB

More Related Content

What's hot

Vs c# lecture11
Vs c# lecture11Vs c# lecture11
Vs c# lecture11
Saman M. Almufti
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
Soluto
 
React tips
React tipsReact tips
React tips
Vedran Maršić
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
Doeun KOCH
 
React lecture
React lectureReact lecture
React lecture
Christoffer Noring
 
Rxjs swetugg
Rxjs swetuggRxjs swetugg
Rxjs swetugg
Christoffer Noring
 
React js use contexts and useContext hook
React js use contexts and useContext hookReact js use contexts and useContext hook
React js use contexts and useContext hook
Piyush Jamwal
 
Deceptive simplicity of async and await
Deceptive simplicity of async and awaitDeceptive simplicity of async and await
Deceptive simplicity of async and await
Andrei Marukovich
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
First Tuesday Bergen
 
Dependency Injection for Android
Dependency Injection for AndroidDependency Injection for Android
Dependency Injection for Android
First Tuesday Bergen
 
React hooks beyond hype
React hooks beyond hypeReact hooks beyond hype
React hooks beyond hype
Magdiel Duarte
 
Ajax Part II
Ajax Part IIAjax Part II
Ajax Part II
Mukesh Tekwani
 

What's hot (17)

Vs c# lecture11
Vs c# lecture11Vs c# lecture11
Vs c# lecture11
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
React tips
React tipsReact tips
React tips
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
Presentation cs313 (1)
Presentation cs313 (1)Presentation cs313 (1)
Presentation cs313 (1)
 
Lesson3
Lesson3Lesson3
Lesson3
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 
React lecture
React lectureReact lecture
React lecture
 
AutoComplete
AutoCompleteAutoComplete
AutoComplete
 
16 18
16 1816 18
16 18
 
Rxjs swetugg
Rxjs swetuggRxjs swetugg
Rxjs swetugg
 
React js use contexts and useContext hook
React js use contexts and useContext hookReact js use contexts and useContext hook
React js use contexts and useContext hook
 
Deceptive simplicity of async and await
Deceptive simplicity of async and awaitDeceptive simplicity of async and await
Deceptive simplicity of async and await
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
 
Dependency Injection for Android
Dependency Injection for AndroidDependency Injection for Android
Dependency Injection for Android
 
React hooks beyond hype
React hooks beyond hypeReact hooks beyond hype
React hooks beyond hype
 
Ajax Part II
Ajax Part IIAjax Part II
Ajax Part II
 

Viewers also liked

Olli september26
Olli september26Olli september26
Olli september26
Richard Beach
 
How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...
How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...
How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...
Richard Beach
 
маркетинг в сфере услуг
маркетинг в сфере услугмаркетинг в сфере услуг
маркетинг в сфере услуг
Nastena8
 
Howto Facebook
Howto FacebookHowto Facebook
Howto Facebook
Richard Beach
 
올챙이로 살펴보는 Eclipse개발
올챙이로 살펴보는 Eclipse개발올챙이로 살펴보는 Eclipse개발
올챙이로 살펴보는 Eclipse개발
cho hyun jong
 
Huw Davies Better By Design V3
Huw Davies Better By Design V3Huw Davies Better By Design V3
Huw Davies Better By Design V3Marina111
 
Den attraktiva gymnasieskolan
Den attraktiva gymnasieskolanDen attraktiva gymnasieskolan
Den attraktiva gymnasieskolan
Hanna Metsis
 
Creating A Facebook Fan Page
Creating A Facebook  Fan  PageCreating A Facebook  Fan  Page
Creating A Facebook Fan Page
brandvines
 
Lawrenceroleplay
LawrenceroleplayLawrenceroleplay
Lawrenceroleplay
Richard Beach
 
Video Marketing Tips from A to Z with Judy B handouts
Video Marketing Tips from A to Z with Judy B handoutsVideo Marketing Tips from A to Z with Judy B handouts
Video Marketing Tips from A to Z with Judy B handoutsbrandvines
 
Smash - Richard Lavigne
Smash - Richard LavigneSmash - Richard Lavigne
Smash - Richard Lavigneguest6028901
 
Olli oct17 workplace
Olli oct17 workplaceOlli oct17 workplace
Olli oct17 workplace
Richard Beach
 
Eclipse basic(조현종)
Eclipse basic(조현종)Eclipse basic(조현종)
Eclipse basic(조현종)cho hyun jong
 
Women Of Restoration 2009 Speakers
Women Of Restoration 2009 SpeakersWomen Of Restoration 2009 Speakers
Women Of Restoration 2009 Speakersguestfda721
 
Worry free guide to web video
Worry free guide to web videoWorry free guide to web video
Worry free guide to web video
brandvines
 

Viewers also liked (20)

Olli september26
Olli september26Olli september26
Olli september26
 
How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...
How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...
How Affordances of Digital Tool Use Foster Critical Literacy: GCLR Webinar pr...
 
маркетинг в сфере услуг
маркетинг в сфере услугмаркетинг в сфере услуг
маркетинг в сфере услуг
 
Howto Facebook
Howto FacebookHowto Facebook
Howto Facebook
 
Swt J Face 2/3
Swt J Face 2/3Swt J Face 2/3
Swt J Face 2/3
 
Corporate Pitch 1107
Corporate Pitch 1107Corporate Pitch 1107
Corporate Pitch 1107
 
올챙이로 살펴보는 Eclipse개발
올챙이로 살펴보는 Eclipse개발올챙이로 살펴보는 Eclipse개발
올챙이로 살펴보는 Eclipse개발
 
Huw Davies Better By Design V3
Huw Davies Better By Design V3Huw Davies Better By Design V3
Huw Davies Better By Design V3
 
Den attraktiva gymnasieskolan
Den attraktiva gymnasieskolanDen attraktiva gymnasieskolan
Den attraktiva gymnasieskolan
 
Swt J Face 1/3
Swt J Face 1/3Swt J Face 1/3
Swt J Face 1/3
 
Creating A Facebook Fan Page
Creating A Facebook  Fan  PageCreating A Facebook  Fan  Page
Creating A Facebook Fan Page
 
Msu standards pp
Msu standards ppMsu standards pp
Msu standards pp
 
Child abuse ppt
Child abuse pptChild abuse ppt
Child abuse ppt
 
Lawrenceroleplay
LawrenceroleplayLawrenceroleplay
Lawrenceroleplay
 
Video Marketing Tips from A to Z with Judy B handouts
Video Marketing Tips from A to Z with Judy B handoutsVideo Marketing Tips from A to Z with Judy B handouts
Video Marketing Tips from A to Z with Judy B handouts
 
Smash - Richard Lavigne
Smash - Richard LavigneSmash - Richard Lavigne
Smash - Richard Lavigne
 
Olli oct17 workplace
Olli oct17 workplaceOlli oct17 workplace
Olli oct17 workplace
 
Eclipse basic(조현종)
Eclipse basic(조현종)Eclipse basic(조현종)
Eclipse basic(조현종)
 
Women Of Restoration 2009 Speakers
Women Of Restoration 2009 SpeakersWomen Of Restoration 2009 Speakers
Women Of Restoration 2009 Speakers
 
Worry free guide to web video
Worry free guide to web videoWorry free guide to web video
Worry free guide to web video
 

Similar to mediator

Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
Stefano Fago
 
OBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .pptOBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .ppt
SaadAsim11
 
Improving Correctness with Types Kats Conf
Improving Correctness with Types Kats ConfImproving Correctness with Types Kats Conf
Improving Correctness with Types Kats Conf
Iain Hull
 
25-inheritance-polymorphism.ppt
25-inheritance-polymorphism.ppt25-inheritance-polymorphism.ppt
25-inheritance-polymorphism.ppt
PiyushAery
 
Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Benelux
yohanbeschi
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
LearningTech
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Julie Iskander
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive Shell
Giovanni Lodi
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
Tareq Hasan
 
Javascript foundations: Introducing OO
Javascript foundations: Introducing OOJavascript foundations: Introducing OO
Javascript foundations: Introducing OO
John Hunter
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMMario Fusco
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objectsPhúc Đỗ
 
Javascript
JavascriptJavascript
Javascript
Gita Kriz
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced JavascriptAdieu
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
relay12
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
Rodica Dada
 
Java script
Java scriptJava script
Java script
Yoga Raja
 
properties-how-do-i - Transcript.pdf
properties-how-do-i - Transcript.pdfproperties-how-do-i - Transcript.pdf
properties-how-do-i - Transcript.pdf
ShaiAlmog1
 

Similar to mediator (20)

mediator2
mediator2mediator2
mediator2
 
Uncommon Design Patterns
Uncommon Design PatternsUncommon Design Patterns
Uncommon Design Patterns
 
OBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .pptOBJECTS IN Object Oriented Programming .ppt
OBJECTS IN Object Oriented Programming .ppt
 
Improving Correctness with Types Kats Conf
Improving Correctness with Types Kats ConfImproving Correctness with Types Kats Conf
Improving Correctness with Types Kats Conf
 
25-inheritance-polymorphism.ppt
25-inheritance-polymorphism.ppt25-inheritance-polymorphism.ppt
25-inheritance-polymorphism.ppt
 
Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Benelux
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
Functional Core, Reactive Shell
Functional Core, Reactive ShellFunctional Core, Reactive Shell
Functional Core, Reactive Shell
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 
Javascript foundations: Introducing OO
Javascript foundations: Introducing OOJavascript foundations: Introducing OO
Javascript foundations: Introducing OO
 
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STMConcurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM
 
11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
 
Javascript
JavascriptJavascript
Javascript
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Oojs 1.1
Oojs 1.1Oojs 1.1
Oojs 1.1
 
Java script
Java scriptJava script
Java script
 
properties-how-do-i - Transcript.pdf
properties-how-do-i - Transcript.pdfproperties-how-do-i - Transcript.pdf
properties-how-do-i - Transcript.pdf
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 

mediator

  • 1.
  • 2. Motivations  lots of classes in the design of framework  If certain principles are not applied the final framework will end in a total mess  to avoid tight coupled frameworks, we need a mechanism to facilitate the interaction between objects in a manner in that objects are not aware of the existence of other objects.
  • 3. Mediator Mediator promotes loose coupling by keeping objects from referring to each other explicitly
  • 4. Intent  Define an object that encapsulates how a set of objects interact.  Design an intermediary to decouple many peers  Promote the many-to-many relationships between interacting peers to “full object status”.
  • 8. Check list  Identify a collection of interacting objects that would benefit from mutual decoupling.  Encapsulate those interactions in the abstraction of a new class.  Create an instance of that new class and rework all “peer” objects to interact with the Mediator only.
  • 9.  Balance the principle of decoupling with the principle of distributing responsibility evenly.  Be careful not to create a “controller” or “god” object.
  • 10. Mediator design example  Let us consider design of a class in which one object send messages to other objects by means of if then if condition explicitly
  • 11. public class WorkerObject { private string _message; public WorkerObject(string message) { _message = message; } public string Message { get{return _message;} set{_message = value;} } public SendMessage(string message) { Console.WriteLine(quot;Message sent : quot; + message); } }
  • 12. WorkerObject senderObject = new WorkerObject(quot;message0quot;); WorkerObject workerObject1 = new WorkerObject(quot;message1quot;); WorkerObject workerObject2 = new WorkerObject(quot;message2quot;); WorkerObject workerObject3 = new WorkerObject(quot;message3quot;); if(!workerObject1.Message.Equals(senderObject.Message)) { workerObject1.SendMessage(senderObject.Message); } if(!workerObject2.Message.Equals(senderObject.Message)) { workerObject2.SendMessage(senderObject.Message); } if(!workerObject3.Message.Equals(senderObject.Message)) { workerObject3.SendMessage(senderObject.Message); }
  • 13. Mediator  we create a mediator class, DoSomeMediation.  This class contains two methods Register and SendMessage  The Register method catalogs all the classes we want to mediate between.  The SendMessage method is where the functional code actually exists
  • 14. public class DoSomeMediation { private static ArrayList _workerObjects = new ArrayList(); public static int Register(WorkerObject workerObject) { return _workerObjects.Add(workerObject); } public static void SendMessage(WorkerObject senderObject) { if(senderObject == null) return; string messageToSend = senderObject.Message; foreach(WorkerObject workerObject in _workerObjects) { //send message to all other objects registered if(!workerObject.Message.Equals(senderObject.Message)) workerObject.SendMessage(messageToSend); } } }
  • 15. WorkerObject senderObject = new WorkerObject(quot;message0quot;); WorkerObject workerObject1 = new WorkerObject(quot;message1quot;); WorkerObject workerObject2 = new WorkerObject(quot;message2quot;); WorkerObject workerObject3 = new WorkerObject(quot;message3quot;); DoSomeMediation.Register(senderObject); DoSomeMediation.Register(workerObject1); DoSomeMediation.Register(workerObject2); DoSomeMediation.Register(workerObject3); DoSomeMediation.SendMessage(senderObject);
  • 16. Flow diagram WorkerObj1 Mediator SenderObj Worker Obj2
  • 17. CCS Model  SenderObject(reg,sendmedmsg,sendobjmsg,printmsg)= reg.sendmedmsg’.SenderObject<reg,sendmedmsg,sendobjmsg,printms g>  Mediator(sendmedmsg,sendobj1msg,sendobj2msg)= sendmedmsg.sendobj1msg’.Mediator<sendmedmsg,sendobj1msg,sendo bj2msg> + sendmedmsg.sendobj2msg’.Mediator<sendmedmsg,sendobj1msg,send obj2msg>  Workerobj1(reg,sendmedmsg,sendobjmsg,printmsg)=sendobjmsg.prin tmsg’.Workerobj1<reg,sendmedmsg,sendobjmsg,printmsg>  Workerobj2(reg,sendmedmsg,sendobjmsg,printmsg)=sendobjmsg.prin tmsg’.Workerobj2<reg,sendmedmsg,sendobjmsg,printmsg>