<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vkhuran</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vkhuran"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Vkhuran"/>
	<updated>2026-06-07T20:26:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=70616</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=70616"/>
		<updated>2012-11-19T17:53:30Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
For Example: When the Pathology department needs X-Ray report from the Radiology department(which is handled by the 'generateXRay()' method of the Radiology department) it calls it's 'getXRay()' method. &lt;br /&gt;
&lt;br /&gt;
Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example: the 'getXRay()' method of the Pathology department is now inside the Hospital Management Mediator and is called only of the patient is of type 'Pathology Patient'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
* It is the only smart delegating object&lt;br /&gt;
* Reduces subclassing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Disadvantages of Mediator Pattern===&lt;br /&gt;
* It increases complexity. It tends to become more complex if more classes are added.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which they can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, the patient has access to the facade interface and can only call the 'getFullReport()' method to obtain the checkup reports. &lt;br /&gt;
&lt;br /&gt;
The 'getFullReport()' method in turn calls various methods of various departments. Thus the patient is unaware of the implementation of these methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface.&lt;br /&gt;
&lt;br /&gt;
The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable.&lt;br /&gt;
&lt;br /&gt;
Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. &lt;br /&gt;
&lt;br /&gt;
The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. &lt;br /&gt;
&lt;br /&gt;
Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69805</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69805"/>
		<updated>2012-11-17T06:24:04Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling. &lt;br /&gt;
&lt;br /&gt;
For Example: When the Pathology department needs X-Ray report from the Sonography department it calls the 'getXRay()' method. Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. &lt;br /&gt;
&lt;br /&gt;
Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments. &lt;br /&gt;
&lt;br /&gt;
For example: the 'getXRay()' method of the Pathology department is now inside the Hospital Management Mediator and is called only of the patient is of type 'Pathology Patient'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
In this example, the patient has access to the facade interface and can only call the 'getFullReport()' method to obtain the checkup reports. The 'getFullReport()' method in turn calls various methods of various departments. Thus the patient is unaware of the implementation of these methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable.&lt;br /&gt;
&lt;br /&gt;
Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69802</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69802"/>
		<updated>2012-11-17T06:22:40Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling. &lt;br /&gt;
&lt;br /&gt;
For Example: When the Pathology department needs X-Ray report from the Sonography department it calls the 'getXRay()' method. Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. &lt;br /&gt;
&lt;br /&gt;
Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments. &lt;br /&gt;
&lt;br /&gt;
For example: the 'getXRay()' method of the Pathology department is now inside the Hospital Management Mediator and is called only of the patient is of type 'Pathology Patient'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
In this example, the patient has access to the facade interface and can only call the 'getFullReport()' method to obtain the checkup reports. The 'getFullReport()' method in turn calls various methods of various departments. Thus the patient is unaware of the implementation of these methods.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable.&lt;br /&gt;
&lt;br /&gt;
Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69796</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69796"/>
		<updated>2012-11-17T06:18:02Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling. &lt;br /&gt;
&lt;br /&gt;
For Example: When the Pathology department needs X-Ray report from the Sonography department it calls the 'getXRay()' method. Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. &lt;br /&gt;
&lt;br /&gt;
Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments. &lt;br /&gt;
&lt;br /&gt;
For example: the 'getXRay()' method of the Pathology department is now inside the Hospital Management Mediator and is called only of the patient is of type 'Pathology Patient'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable.&lt;br /&gt;
&lt;br /&gt;
Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69793</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69793"/>
		<updated>2012-11-17T06:16:47Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling. &lt;br /&gt;
&lt;br /&gt;
For Example: When the Pathology department needs X-Ray report from the Sonography department it calls the 'getXRay()' method. Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. &lt;br /&gt;
&lt;br /&gt;
Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments. &lt;br /&gt;
&lt;br /&gt;
For example: the 'getXRay()' method of the Pathology department is now inside the Hospital Management Mediator and is called only of the patient is of type 'Pathology Patient'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69792</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69792"/>
		<updated>2012-11-17T06:15:36Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling. &lt;br /&gt;
&lt;br /&gt;
For Example: When the Pathology department needs X-Ray report from the Sonography department it calls the 'getXRay()' method. Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments. &lt;br /&gt;
&lt;br /&gt;
For example: the 'getXRay()' method of the Pathology department is now inside the Hospital Management Mediator and is called only of the patient is of type 'Pathology Patient'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69790</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69790"/>
		<updated>2012-11-17T06:13:55Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling. For Example: When the Pathology department needs X-Ray report from the Sonography department it calls the 'getXRay()' method. Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments. For example: the 'getXRay()' method of the Pathology department is now inside the Hospital Management Mediator and is called only of the patient is of type 'Pathology Patient'.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69789</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69789"/>
		<updated>2012-11-17T06:07:15Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Case1: Without the use of Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling. For Example: When the Pathology department needs X-Ray report from the Sonography department it calls the 'getXRay()' method. Similarly, there are other methods which are often required by other departments.&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012&amp;diff=69788</id>
		<title>CSC/ECE 517 Fall 2012</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012&amp;diff=69788"/>
		<updated>2012-11-17T06:02:08Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE_517_Fall_2012/Table_Of_Contents]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 n xx]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w1 rk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w20 pp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w5 su]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w6 pp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w4 aj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w7 am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w8 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w9 av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w10 pk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w11 ap]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w12 mv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w14 gv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w17 ir]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w18 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w22 an]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w21 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w21 wi]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w31 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w16 br]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w23 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w24 nr]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w15 rt]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w3 pl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w32 cm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w5 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w37 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w67 ks]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w27 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w29 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w33 op]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w19 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w34 vd]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w35 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w30 rp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w58 am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w47 sk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w69 mv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w44 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w45 is]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w53 kc]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w40 ar]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w39 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w54 go]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w56 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w64 nn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w66 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w40 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w42 js]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w46 sm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w71 gs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w63 dv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w55 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w57 mp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w52 an]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch1b 1w38 nm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w60 ac]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w62 rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w29 st]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w3_sm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w30 an]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w17 pt]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w31 up]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w9 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w19 is]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w26 aj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w5 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w16 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w8 vp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w18 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w3 jm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w23 sr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w11_aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w15 rr]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w33 pv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w20_aa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w14_bb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w21_ap]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w13_sm]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w4_sa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w25_nr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w12_sv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w7_ma]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w6_ar]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w32_mk]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w10_rc]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w70_sm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w67_sk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w40_sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w22_sk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w-1w65_am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w59_bc]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w60_ns]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w69_as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w39_ka]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w36_av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w37_ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w43_iv]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69787</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69787"/>
		<updated>2012-11-17T05:58:46Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
===Case1: Without the use of Mediator Pattern===&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case2: With the use of Mediator Pattern===&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advantages of Mediator Pattern===&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Facade Pattern==&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with facade pattern==&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Observer Pattern==&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Comparison of mediator pattern with observer pattern==&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69786</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69786"/>
		<updated>2012-11-17T05:54:34Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator and related patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://www.blackwasp.co.uk/Mediator.aspx Mediator Design Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69785</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69785"/>
		<updated>2012-11-17T05:51:56Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mediator and related patterns=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mediator_pattern Mediator Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Facade_pattern Facade Pattern]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Observer_pattern Observer Pattern]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69784</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69784"/>
		<updated>2012-11-17T05:49:07Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Pattern=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69783</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69783"/>
		<updated>2012-11-17T05:48:26Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Pattern=&lt;br /&gt;
==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
==Other References==&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69782</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69782"/>
		<updated>2012-11-17T05:45:07Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
==Other References==&lt;br /&gt;
*[http://catalog.lib.ncsu.edu/record/NCSU1994709 Head First Design Patterns]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69781</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69781"/>
		<updated>2012-11-17T05:38:52Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. It is a structural pattern&amp;lt;ref name=&amp;quot;wikistructural&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Structural_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69780</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69780"/>
		<updated>2012-11-17T05:35:54Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling&amp;lt;ref name=&amp;quot;wikiloosecoupling&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Loose_coupling&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69779</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69779"/>
		<updated>2012-11-17T05:32:11Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref name=&amp;quot;wikibehav&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;br&amp;gt;&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69778</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69778"/>
		<updated>2012-11-17T05:25:41Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern&amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Behavioral_pattern&amp;lt;/ref&amp;gt;. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with observer pattern===&lt;br /&gt;
*The mediator pattern differs from observer pattern in terms of usage. In order to avoid explicit communication between two or more objects mediator is used. Whereas observer pattern is used in situations where an object changes its state all its dependents are notified and updated automatically to reflect this change.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
 1. ^ http://en.wikipedia.org/wiki/Behavioral_pattern&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69777</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69777"/>
		<updated>2012-11-17T04:55:28Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;br /&gt;
&lt;br /&gt;
In this case there is one subject and three dependent objects. The Hospital Management Subject implements the Subject interface. The three dependents/observers are Radiology, Physiology, and Surgery and they implement the Observer interface. The Hospital Management Subject includes a method 'getBloodCount()' which sets the value of blood count variable. Whenever the value of this variable for a particular patient changes the observers get notified of the change because they are registered with the subject. The 'notify()' method calls the 'update()' method on the observer which sets the value in the observer objects.&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69771</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69771"/>
		<updated>2012-11-17T04:43:06Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
&lt;br /&gt;
[[File:image3_observer.png|650 px|thumb|right|Example: Using Observer Pattern]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image3_observer.png&amp;diff=69770</id>
		<title>File:Image3 observer.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image3_observer.png&amp;diff=69770"/>
		<updated>2012-11-17T04:42:49Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69749</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69749"/>
		<updated>2012-11-17T02:59:39Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Advantages of Mediator Pattern====&lt;br /&gt;
* It facilitates re-usability of objects. It is possible due to the fact that objects are decoupled from the system.&lt;br /&gt;
* Overall maintenance of the system gets simplified because the control logic is encapsulated in the mediator.&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Observer Pattern===&lt;br /&gt;
&lt;br /&gt;
In an observer pattern an object maintains a list of all its dependents. Thus if any state changes occurs the object notifies all the dependents. The state of an object is an important concern. Whenever state change occurs the objects are updated automatically. All the common components are maintained in an abstraction called ‘subject’ whereas all the variable components are maintained in an abstraction called ‘object’. It is also known as publish-subscribe pattern.  One example of observer pattern can be an event management process. Whenever an event takes place it should be notified to all other objects so that their state gets updated.&lt;br /&gt;
&lt;br /&gt;
====Example=====&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69745</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69745"/>
		<updated>2012-11-17T02:21:40Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Facade Pattern===&lt;br /&gt;
A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this case a facade pattern provides an interface to the patients through which he can interact with the departments. The internal details of the departments are hidden from the patient. So whenever he needs to get any service from any of the department he only communicates with the interface. The patient may not be provided with all the functionality and he is exposed to only certain functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
*Mediator pattern is a behavioral pattern whereas facade pattern is a structural pattern.&lt;br /&gt;
&lt;br /&gt;
*Mediator pattern adds extra functionality whereas facade pattern doesn’t add any extra functionality. It only provides an interface to an existing subsystem.&lt;br /&gt;
&lt;br /&gt;
*The components of a subsystem do not have any knowledge about the facade whereas the colleagues have the knowledge of the mediator.&lt;br /&gt;
&lt;br /&gt;
So if we see the above examples we can clearly understand that mediator pattern avoids coupling within a sub-system whereas facade pattern avoids coupling between sub-system and between sub-system and an external entity.&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69740</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69740"/>
		<updated>2012-11-17T01:56:30Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Mediator Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
====Facade Pattern====&lt;br /&gt;
First of all let us see what facade pattern is. A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facadepattern.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image3_facadepattern.png&amp;diff=69739</id>
		<title>File:Image3 facadepattern.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image3_facadepattern.png&amp;diff=69739"/>
		<updated>2012-11-17T01:56:23Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69738</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69738"/>
		<updated>2012-11-17T01:54:31Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Comparison of mediator pattern with facade pattern===&lt;br /&gt;
====Facade Pattern====&lt;br /&gt;
First of all let us see what facade pattern is. A Facade design pattern provides a unified interface to a larger body of code. This makes the use of subsystem easy. This pattern wraps the complicated subsystem with a simple interface. A facade pattern shields users from the complex inner details of the subsystem. Example of facade pattern could be of a web service where users can get access to the small services without knowing anything about their internal structures. They just need an interface which facade pattern provides.&lt;br /&gt;
&lt;br /&gt;
For the same example as discussed above let us see how a facade pattern looks.&lt;br /&gt;
&lt;br /&gt;
[[File:image3_facade.png|650 px|thumb|right|Example: Using Facade Pattern]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image3_facade.png&amp;diff=69737</id>
		<title>File:Image3 facade.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image3_facade.png&amp;diff=69737"/>
		<updated>2012-11-17T01:54:14Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69734</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69734"/>
		<updated>2012-11-17T01:45:25Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;br /&gt;
This facilitates loose coupling as the departments do not need to communicate with each other explicitly. They also do not need to know about internal details of other departments.&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69733</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69733"/>
		<updated>2012-11-17T01:41:13Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a Hospital Management Mediator which sits in between all the departments and all the communication among them is handled by the mediator. The control logic of the entire system is included in the mediator. Whenever a new department is added or some functionality of an existing department needs to be changed, only the mediator control logic needs to be modified.&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image2_withmediator.png&amp;diff=69732</id>
		<title>File:Image2 withmediator.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image2_withmediator.png&amp;diff=69732"/>
		<updated>2012-11-17T01:22:01Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: uploaded a new version of &amp;amp;quot;File:Image2 withmediator.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image2_withmediator.png&amp;diff=69731</id>
		<title>File:Image2 withmediator.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image2_withmediator.png&amp;diff=69731"/>
		<updated>2012-11-17T01:21:12Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69730</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69730"/>
		<updated>2012-11-17T01:20:33Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Case2: With the use of Mediator Pattern====&lt;br /&gt;
[[File:Image2_withmediator.png|650 px|thumb|right|Example: Using Mediator Pattern]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To reduce coupling in the above example we add a&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69729</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69729"/>
		<updated>2012-11-17T01:05:50Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
====Case1: Without the use of Mediator Pattern====&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|right|Example: Without using Mediator Pattern]]&lt;br /&gt;
In this example, there are four departments of a hospital, namely :Pathology, Radiology, Surgery and Physiology. When one department needs some data from another department, they need to explicitly contact the other department for that data. Since these departments directly interact with each other, the communication between these parties is very complex and results in high coupling.&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69724</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69724"/>
		<updated>2012-11-17T00:45:17Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|center|Example: Without using Mediator Pattern]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69721</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69721"/>
		<updated>2012-11-17T00:42:52Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;br /&gt;
[[File:Image1_womediator1.png|650 px|thumb|center|Example_notMediator]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator1.png&amp;diff=69720</id>
		<title>File:Image1 womediator1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator1.png&amp;diff=69720"/>
		<updated>2012-11-17T00:42:37Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69719</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69719"/>
		<updated>2012-11-17T00:41:13Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;br /&gt;
[[File:Image1_womediator.png|650 px|thumb|center|Example_notMediator]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69717</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69717"/>
		<updated>2012-11-17T00:38:26Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;br /&gt;
[[File:Image1_womediator.png|650 px|thumb|right|Example_notMediator]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69716</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69716"/>
		<updated>2012-11-17T00:36:22Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;br /&gt;
[[File:Image1_womediator|650 px|thumb|right|Example_notMediator]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69715</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69715"/>
		<updated>2012-11-17T00:35:11Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;br /&gt;
[[File:Image1_womediator|650 px|thumb|right|Example_notMediator &amp;lt;ref name=&amp;quot;withoutMediator&amp;quot; /&amp;gt;&lt;br /&gt;
]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator.png&amp;diff=69714</id>
		<title>File:Image1 womediator.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator.png&amp;diff=69714"/>
		<updated>2012-11-17T00:32:24Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: uploaded a new version of &amp;amp;quot;File:Image1 womediator.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator.png&amp;diff=69713</id>
		<title>File:Image1 womediator.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator.png&amp;diff=69713"/>
		<updated>2012-11-17T00:32:23Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: uploaded a new version of &amp;amp;quot;File:Image1 womediator.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69712</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69712"/>
		<updated>2012-11-17T00:31:25Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator.png&amp;diff=69710</id>
		<title>File:Image1 womediator.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Image1_womediator.png&amp;diff=69710"/>
		<updated>2012-11-17T00:29:18Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69709</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w43 iv</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w43_iv&amp;diff=69709"/>
		<updated>2012-11-17T00:28:18Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: Created page with &amp;quot;==Mediator Pattern== ===Introduction=== Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interact...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Mediator Pattern==&lt;br /&gt;
===Introduction===&lt;br /&gt;
Mediator pattern comes under the category of behavioral pattern. It specifies an object that includes the encapsulation about the interaction among various objects.&lt;br /&gt;
&lt;br /&gt;
It prevents objects to interact with each other explicitly and thus it facilitates loose coupling. In other words it handles complex communication among related objects. All the objects communicate with the mediator when they want to interact with each other. Thus it improves maintainability.&lt;br /&gt;
&lt;br /&gt;
All the classes which interact with the mediator are called colleagues. These colleagues know who their mediator is and the mediator also knows which colleagues can interact with it. The colleagues send messages to the mediator object. The mediator sends message to other classes. Thus the object which initiated this communication does not need to have knowledge about other objects. All they need to know is about their mediator who is responsible to carry out this communication.&lt;br /&gt;
&lt;br /&gt;
Following classes/objects take part in this process:&lt;br /&gt;
&lt;br /&gt;
'''Mediator''': Provides interface for communication among colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Concrete Mediator''': It coordinates the colleagues and implements cooperative behavior. It also holds information about the colleagues.&lt;br /&gt;
&lt;br /&gt;
'''Colleague Classes''': Colleague classes know about their mediator.&lt;br /&gt;
&lt;br /&gt;
A real life example of mediator pattern can be of an airport control tower. It is the job of this tower to control all the planes. It decides which plane will take-off and land at what time rather than plane to plane communication.&lt;br /&gt;
&lt;br /&gt;
Another example of mediator pattern&lt;br /&gt;
&lt;br /&gt;
[[File:C:\Users\VARUN\Desktop\Image1_womediator.png|thumb|alt=text|Caption]]&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w34_vd&amp;diff=65198</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w34 vd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w34_vd&amp;diff=65198"/>
		<updated>2012-09-19T16:29:42Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Object oriented languages support inheritance through different mechanisms. Methods from parent classes can be re-implemented in child classes to improve the behavior of the child class without having to re-write the whole class or define a completely new method. As method re-implementation in descendant classes is achieved differently in different classes it is crucial to understand these mechanisms.&lt;br /&gt;
&lt;br /&gt;
==Re- implantation of methods in PHP 5==&lt;br /&gt;
The object model in PHP 5 was rewritten to include OO features such as final, abstract and visibility for classes and methods and improve the overall performance of the language. Re-implantation of methods in PHP 5 can be achieved in the following manner:&lt;br /&gt;
&lt;br /&gt;
===Object Inheritance===&lt;br /&gt;
This is an important OO feature that PHP uses in its object model. When a subclass extends from a parent class, it inherits all the public and protected methods from the parent class. The issues that affect how the inherited methods behave are:&lt;br /&gt;
&lt;br /&gt;
====Method Visibility====&lt;br /&gt;
All methods that are defined as ‘public’ and ‘protected’ in the parent class are ‘visible’ in the subclass. Public and protected are access modifiers that define the visibility of methods between different classes. Methods defined as ‘private’ access are not visible in the subclass. Methods declared without any access keyword are ‘public’.&lt;br /&gt;
&amp;lt;br/&amp;gt;Example:&lt;br /&gt;
 &amp;lt;?php &lt;br /&gt;
 class GameClass&lt;br /&gt;
 { &lt;br /&gt;
  public function_construct(){ } //Declare a public constructor &amp;lt;br/&amp;gt; public function GamePublic(){ } //Declare a public method&amp;lt;br/&amp;gt;protected function GameProtected(){ } //Declare a protected method&amp;lt;br/&amp;gt;private function GamePrivate(){ }  //Declare a private method&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;function Play()  //This is public&amp;lt;br/&amp;gt;{&lt;br /&gt;
  $this-&amp;gt;GamePublic();&lt;br /&gt;
 $this-&amp;gt;GameProtected();&lt;br /&gt;
 $this-&amp;gt;GamePrivate(); &lt;br /&gt;
 } &lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 $mygame = new GameClass;&amp;lt;br/&amp;gt;$mygame-&amp;gt;GamePublic(); // Works&amp;lt;br/&amp;gt;$mygame-&amp;gt;GameProtected(); // Fatal Error&amp;lt;br/&amp;gt;$mygame-&amp;gt;GamePrivate(); // Fatal Error&amp;lt;br/&amp;gt;$mygame-&amp;gt;Play(); // Public, Protected and Private work   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;class BoardGame extends GameClass &lt;br /&gt;
 {&amp;lt;br/&amp;gt;//This is public&amp;lt;br/&amp;gt; function PlayDice()&amp;lt;br/&amp;gt;{ &amp;lt;br/&amp;gt;$this-&amp;gt;GamePublic();&amp;lt;br/&amp;gt; $this-&amp;gt;GameProtected();&amp;lt;br/&amp;gt; $this-&amp;gt;GamePrivate(); // Fatal Error &amp;lt;br/&amp;gt; } &amp;lt;br/&amp;gt;}&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;$myboard = new BoardGame;&amp;lt;br/&amp;gt;$myboard-&amp;gt;GamePublic(); // Works &amp;lt;br/&amp;gt;$myboard-&amp;gt;PlayDice(); // Public and Protected work, not Private &lt;br /&gt;
&lt;br /&gt;
====Overriding====&lt;br /&gt;
If a subclass defines a new method with the same name and signature as that of the method from the parent class then an object of the subclass calling that method will execute the implementation of the method defined in the subclass.&lt;br /&gt;
Example: change this example of overriding&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class game&lt;br /&gt;
 {&lt;br /&gt;
 public function game-name($string)&lt;br /&gt;
  {&lt;br /&gt;
  echo 'Game: ' . $string . PHP_EOL;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
 public function play()&lt;br /&gt;
  {&lt;br /&gt;
  echo 'I like this game.' . PHP_EOL;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 class chess-game extends game&lt;br /&gt;
 {&lt;br /&gt;
  public function game-name($string)&lt;br /&gt;
  {&lt;br /&gt;
  echo 'Board Game: ' . $string . PHP_EOL;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 $gm = new game ();&lt;br /&gt;
 $cg = new chess-game();&lt;br /&gt;
 $game-&amp;gt;game-name('cricket'); // Output: 'Game: cricket'&lt;br /&gt;
 $gm-&amp;gt;play();       // Output: 'I like this game' &lt;br /&gt;
 $cg-&amp;gt;game-name('chess'); // Output: 'Board Game: chess'&lt;br /&gt;
 $cg-&amp;gt;play();       // Output: 'I like this game'&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
====Scope Resolution====&lt;br /&gt;
When a subclass extends a class, then the overridden and overloaded methods of the parent class can be called, using the scope resolution operator (::) inside the subclass.&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class ParentClass&lt;br /&gt;
 {&lt;br /&gt;
 protected function parentFunc()&lt;br /&gt;
  {&lt;br /&gt;
  echo &amp;quot;ParentClass::parentFunc()\n&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 class ChildClass extends ParentClass&lt;br /&gt;
 {&lt;br /&gt;
 // Override parent's definition&lt;br /&gt;
 public function parentFunc()&lt;br /&gt;
  {&lt;br /&gt;
  // Call the parent function&lt;br /&gt;
  parent::parentFunc();&lt;br /&gt;
  echo &amp;quot;ChildClass::parentFunc()\n&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 $class = new ChildClass();&lt;br /&gt;
 $class-&amp;gt;parentFunc();&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 Output&lt;br /&gt;
 ParentClass::parentFunc()&lt;br /&gt;
 ChildClass::parentFunc()&lt;br /&gt;
&lt;br /&gt;
===Class Abstraction===&lt;br /&gt;
&lt;br /&gt;
Abstract methods in PHP 5 are methods inside abstract class that only provide signature for the method without any actual implementation to it. An abstract method has an abstract keyword at the beginning of the method declaration. A class containing even a single abstract method should be declared as abstract by adding the abstract keyword to its declaration. Any class inheriting from an abstract class should provide implementation of all of the abstract methods or declare it abstract. No class can inherit from more than one abstract class. The inheriting class, should have the same signature for the inherited abstract methods and the same or less restrictive visibility as defined in the methods in the abstract class.&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 abstract class ParentAbstractClass&lt;br /&gt;
 {&lt;br /&gt;
  // Method without definition&lt;br /&gt;
  abstract protected function getName();&lt;br /&gt;
  abstract protected function setName($name);&lt;br /&gt;
  // Method with definition&lt;br /&gt;
  public function printName()&lt;br /&gt;
  {&lt;br /&gt;
   print $this-&amp;gt;getName() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 class ConcreteChild extends ParentAbstractClass&lt;br /&gt;
 {&lt;br /&gt;
  //Method from abstract class implemeted&lt;br /&gt;
  protected function getName() &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  //Method from abstract class implemeted&lt;br /&gt;
  public function setName($name) &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild : {$name}&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 class ConcreteChild2 extends ParentAbstractClass&lt;br /&gt;
 {&lt;br /&gt;
 //Method from abstract class implemeted&lt;br /&gt;
  public function getname() &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild2&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 //Method from abstract class implemeted&lt;br /&gt;
  public function setName($name) &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild2 : {$name}&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 $class1 = new ConcreteChild;&lt;br /&gt;
 $class1-&amp;gt;printName();&lt;br /&gt;
 echo $class1-&amp;gt;setName('FOO') .&amp;quot;\n&amp;quot;;&lt;br /&gt;
 $class2 = new ConcreteChild2;&lt;br /&gt;
 $class2-&amp;gt;printName();&lt;br /&gt;
 echo $class2-&amp;gt;setName('FOO') .&amp;quot;\n&amp;quot;;&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 The above example will output:&lt;br /&gt;
 ConcreteChild&lt;br /&gt;
 ConcreteChild : FOO&lt;br /&gt;
 ConcreteChild2&lt;br /&gt;
 ConcreteChild2 : FOO&lt;br /&gt;
&lt;br /&gt;
===Object Interfaces===&lt;br /&gt;
Interface in PHP is a mechanism that specifies methods that a class requires to implement, without having to provide any implementation to these methods inside the interface. An interface is declared like any other class, just that it is prefixed by the interface keyword and none of its methods have any content to them. A class providing implementation of the methods of an interface has the implements keyword followed by the class name for that class.&lt;br /&gt;
Similarly, an interface can be inherited by another interface so that, a class implementing the interface that is lowest in the inheritance hierarchy gets to implement the methods from all the interfaces.&lt;br /&gt;
Methods inside the interface being implemented by a class should have the same signature as that of the interface.&lt;br /&gt;
Note: An interface cannot be instantiated.&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 interface food&lt;br /&gt;
 {&lt;br /&gt;
 //Interface method with no implementation&lt;br /&gt;
  public function eat();&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;br/&amp;gt;interface fruit&lt;br /&gt;
 {&lt;br /&gt;
 //Interface method with no implementation&lt;br /&gt;
  public function fruitName();&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;br/&amp;gt;interface Apple extends food, fruit&lt;br /&gt;
 {&lt;br /&gt;
 //Interface method with no implementation&lt;br /&gt;
  public function juice();&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;br/&amp;gt;class GreenApple implements Apple&lt;br /&gt;
 {&lt;br /&gt;
 //Implementing methods from all the interfaces&lt;br /&gt;
 public function eat()&lt;br /&gt;
  {&lt;br /&gt;
  echo “Food: eat()”;&lt;br /&gt;
  }&lt;br /&gt;
 public function fruitName()&lt;br /&gt;
  {&lt;br /&gt;
  echo “Fruit: fruitName()”;&lt;br /&gt;
  }&lt;br /&gt;
 public function juice()&lt;br /&gt;
  {&lt;br /&gt;
  echo “Apple: juice()”;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class GreenApple will implement all the methods that it has inherited from all the interfaces in inheritance hierarchy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Objective-C==&lt;br /&gt;
In Objective-C the method declaration is done in the ‘@interface’ section and the method definitions are provided in the ‘@implementation’ section and these two are stored in different files.  &lt;br /&gt;
There are two types of methods in Objective C – &lt;br /&gt;
&amp;lt;br/&amp;gt;1.Instance Methods: Instance methods are denoted by placing a (-) sign before them while declaring them and are used to access and modify the instance variables over a particular instance of a class.&lt;br /&gt;
&lt;br /&gt;
2.Class Methods: Class Methods do not require an object of the Class to be created in order to be called upon. These are very similar to ‘Static’ methods in JAVA. They are denoted by putting a (+) sign before the method name while declaring them. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 myPizza = [Pizza new];	//new is a Class method on Pizza Class &lt;br /&gt;
 [mypizza setcost]	//setcost is an instance method called on the particular instance ‘mypizza’&lt;br /&gt;
&lt;br /&gt;
===Method Overriding===&lt;br /&gt;
Objective-C does not support multiple inheritance and method overloading. However it supports single inheritance and methods can be overridden to re-implement the instance methods in subclasses. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Patient.h class&lt;br /&gt;
 //Interface for Superclass. Here we declare methods and variables&amp;lt;br/&amp;gt;@interface Patient: NSObject 			/*NSObject is the root object and Patient inherits from NSObject*/&lt;br /&gt;
  {						     	&lt;br /&gt;
   int patient_number;				//attributes of patient class              &lt;br /&gt;
   char sex;&lt;br /&gt;
  }&lt;br /&gt;
  @property int patient_number, char sex;&lt;br /&gt;
  -(int) return_patient_number;&lt;br /&gt;
  -(char) return_sex;				/*method declarations for superclass specifying the return type and arguments*/  &lt;br /&gt;
  -(void) setDetails: (int)number : (char)s;		     &lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Patient.m class&lt;br /&gt;
 //Implemetation for Superclass. Here we define methods to modify instance variables&amp;lt;br/&amp;gt;#import  “Patient.h”			//importing interface class&lt;br /&gt;
 @implementation Patient&lt;br /&gt;
  @synthesize patient_number, sex;		//synthesizing instance variables&lt;br /&gt;
  -(void) setDetails : (int)number : (char)s    //method definitions&lt;br /&gt;
    {&lt;br /&gt;
     patient_number=number;&lt;br /&gt;
     sex=s;&lt;br /&gt;
    } &lt;br /&gt;
  -(int) return_patient_number&lt;br /&gt;
    {&lt;br /&gt;
     return patient_number&lt;br /&gt;
    }&lt;br /&gt;
  -(char)return_sex    &lt;br /&gt;
    {&lt;br /&gt;
     return sex&lt;br /&gt;
    }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Now we define a new class that inherits Patient Class&amp;lt;br/&amp;gt;Diabetic.h&lt;br /&gt;
 //interface for the subclass. Here we declare methods for the subclass&amp;lt;br/&amp;gt;#import “Patient.h”		       //importing Superclass’s interface&lt;br /&gt;
 @interface Diabetic : Patient&lt;br /&gt;
  {&lt;br /&gt;
   int blood_sugar;		//additional attribute for the subclass&lt;br /&gt;
  }&lt;br /&gt;
  @property int blood_sugar;&lt;br /&gt;
  -(void) setDetails: (int)number : (char)s : (int)sugar;		//method declarations&lt;br /&gt;
  -(int) return_blood_sugar;&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Diabetic.m&lt;br /&gt;
 //implementation for the subclass&amp;lt;br/&amp;gt;#import “Diabetic.h”			//Subclass importing its own interface&lt;br /&gt;
 @implementation Diabetic: Patient&lt;br /&gt;
  @synthesize blood_sugar;&lt;br /&gt;
  -(void) setDetails: (int)number : (char)s : (int)sugar	//Method Overriding&lt;br /&gt;
   {&lt;br /&gt;
    patient_number=number;&lt;br /&gt;
    sex=s;&lt;br /&gt;
    blood_sugar=sugar;&lt;br /&gt;
   }&lt;br /&gt;
  -(int) return_blood_sugar&lt;br /&gt;
   {&lt;br /&gt;
    return blood_sugar; &lt;br /&gt;
   }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
 //Test program to run the code&amp;lt;br/&amp;gt;# import “Diabetic.h”&lt;br /&gt;
 int main( int argc, char *argv[])&lt;br /&gt;
  {&lt;br /&gt;
   NSAutoreleasepool *pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;
   Diabetic *dia=[[Diabetic alloc] init];&lt;br /&gt;
   [dia setDetails: 10 :’M’ :500];		&lt;br /&gt;
   NSLog( @”Patient number is %i ,Patient Sex is %c, Patient sugar level is %i”, [dia return_patient_number], [dia return_sex ],[dia return_blood_sugar]);&lt;br /&gt;
   [dia release];&lt;br /&gt;
   return 0;&lt;br /&gt;
  }&lt;br /&gt;
Output would be:&lt;br /&gt;
Patient number is 10 ,Patient Sex is M, Patient sugar level is 100&lt;br /&gt;
&lt;br /&gt;
===Abstract Classes===&lt;br /&gt;
Abstract Classes are provided to the users to give them a common interface to interact with the objects.&lt;br /&gt;
There is no access specifier for abstract classes in Objective-C. Users cannot generate pure abstract classes. However a number of abstract classes have been provided to the users. For Example: NSObject in the above example is an abstract class. It cannot be instantiated by the user but is the root class of every class in Objective C.&lt;br /&gt;
&lt;br /&gt;
===Protocols===&lt;br /&gt;
A protocol is similar to Interfaces in JAVA. It specifies a set of behavior/methods that the object who conforms to that protocol must implement. A protocol is defined by using a @protocol directive before the name of the protocol. &lt;br /&gt;
For example:&lt;br /&gt;
 @protocol Alive&lt;br /&gt;
  {&lt;br /&gt;
   : (void) sleep;&lt;br /&gt;
   : (void) eat; &lt;br /&gt;
  }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
If a Class Human conforms to this protocol then it must implement both the methods in it’s implementation section. However it need not declare these methods.&lt;br /&gt;
&lt;br /&gt;
 @ interface Human: NSObject &amp;lt;Alive&amp;gt;&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
 @end&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;#import  “Human.h”			&lt;br /&gt;
 @implementation Human		&lt;br /&gt;
  -(void) sleep		&lt;br /&gt;
  {&lt;br /&gt;
   NSLog(@”I Sleep”);&lt;br /&gt;
  } &lt;br /&gt;
  -(void) eat&lt;br /&gt;
   {&lt;br /&gt;
    NSLog(@”I Eat”);&lt;br /&gt;
   }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
===Categories===&lt;br /&gt;
Categories provide a mechanism to enhance the functionality of a class without subclassing it. You can add new methods to an existing class and also utilize the methods in the existing class by the use of categories. For example:&lt;br /&gt;
&lt;br /&gt;
 @interface Alive: NSObject&lt;br /&gt;
  {&lt;br /&gt;
   : (void) sleep;&lt;br /&gt;
   : (void) eat; &lt;br /&gt;
  }&lt;br /&gt;
 @end&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;#import  ”Alive.h”&lt;br /&gt;
 @interface Alive(OnLiquidDiet)&lt;br /&gt;
  {&lt;br /&gt;
   : (void) sleep;&lt;br /&gt;
   : (void) drinks;&lt;br /&gt;
  }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Here we have defined a new Category ‘OnLiquidDiet’ for the Alive Class which has a different method ‘drinks’ other than the ‘sleep’ method in the Alive Class.&lt;br /&gt;
Although categories can be used for overriding methods, it is not recommended because you cannot access the original method definition once it is overridden in a category. In the above example if we override the ‘sleep’ method in the ‘OnLiquidDiet’ category we won’t be able to access the original ‘sleep’ method from the category.&lt;br /&gt;
&lt;br /&gt;
==Re-implementation of Methods in Python==&lt;br /&gt;
&lt;br /&gt;
Methods can be re-implemented using inheritance in Python, but unlike Objective-C it supports multiple inheritance. However it does not support method overloading.&lt;br /&gt;
In order to implement inheritance the names of the super class separated by commas are defined in the class statement.The Object class is the default base class of all the classes in Python.&lt;br /&gt;
A sample example to show re-implementation of method in the subclass is shown below:&lt;br /&gt;
 class Patient(object):&lt;br /&gt;
  def  __init__(self,patient_number,age,weight):&lt;br /&gt;
   self.patient_number=patient_number&lt;br /&gt;
   self.age=age&lt;br /&gt;
   self.weight=weight&lt;br /&gt;
  def displayDetails(self):&lt;br /&gt;
   return “Patient’s name:” +str(self.patient_number)+ “Patient’s age”+str( self.age),+ “Patient’s weight”+str(self.weight)&lt;br /&gt;
&lt;br /&gt;
Now we define another class that inherits from the Patient Class&lt;br /&gt;
 Class Diabetic (Patient):&lt;br /&gt;
  def __init__(self,patient_ number,age,weight,blood_sugar):&lt;br /&gt;
   super.__init__(patient_ number,age,weight)&lt;br /&gt;
   self.blood_sugar=blood_sugar&lt;br /&gt;
  def displayDetails(self):&lt;br /&gt;
   return super. displayDetails(self)+” Blood Sugar:” + str(self.blood_sugar)&lt;br /&gt;
&lt;br /&gt;
This example typically represents a single inheritance. The Diabetic class overrides the’ __init__’ and ‘displayDetails’ method and in each method a super method call is invoked in order to call the superclass method. If any of these methods were not defined in the subclass and a method call had been invoked on the object of the subclass for that method, then the superclass’s method would have been invoked.&lt;br /&gt;
&lt;br /&gt;
===Abstract Base Classes===&lt;br /&gt;
&lt;br /&gt;
An Abstract Base Class is similar to Interfaces in JAVA and complement duck typing in Python by defining that the class would conform to a given behavior. An abstract class cannot be instantiated and any class that registers to the abstract class must define the abstract methods of the abstract class, though it may choose not to re-implement the methods that had already been defined in the abstract class. The abc module is used for defining an abstract base class. An example to define an abstract class is shown below:&lt;br /&gt;
&lt;br /&gt;
 import abc&lt;br /&gt;
 class PaintBuilding(object):&lt;br /&gt;
  __metaclass__= abc.ABCMeta&lt;br /&gt;
  @abc.abstractmethod&lt;br /&gt;
  def contour():&lt;br /&gt;
   pass&amp;lt;br/&amp;gt;def color():&lt;br /&gt;
   return ”Paint with Red and Blue”&lt;br /&gt;
&lt;br /&gt;
A class needs to register with the Abstract Base Class in order to use it.&lt;br /&gt;
&lt;br /&gt;
 import abc&lt;br /&gt;
 from packageA import PaintBuilding&lt;br /&gt;
 Class PaintRectangularBuilding(object):&lt;br /&gt;
  def contour():&lt;br /&gt;
   return ”Building is Rectangular” &lt;br /&gt;
  def color():&lt;br /&gt;
   return “Paint the Rectangular building Red and Blue”&amp;lt;br/&amp;gt;PaintBuilding.register(PaintRectangularBuilding)&lt;br /&gt;
&lt;br /&gt;
===Multiple Inheritance===&lt;br /&gt;
Since Multiple Inheritance is supported in Python, we can define several classes separated by commas in the class statement. For example:&lt;br /&gt;
 Class Amphibian(LandAnimal,MarineAnimal):&lt;br /&gt;
Since multiple inheritance is prone to conflicts, there is something defined as the Method Resolution Order (MRO) that specifies the sequence in which the method or attribute is looked up in the various super classes. If there is no multiple inheritance then the lookup is done in left to right, depth first order when a particular method on the subclass object is called upon that is not defined in the subclass. However, this approach leads to the same parent being visited more than once if a diamond shaped hierarchy is obtained in case of multiple inheritance. To resolve the conflicts in such cases a new-style MRO has been defined that essentially considers only the rightmost occurrence of any super class and neglects the other occurrences. &lt;br /&gt;
Use of Super keyword&lt;br /&gt;
In Python 3 the super method can be used without any arguments, though the old version of it with arguments is also supported. In order to prevent the same method in the super class being looked up twice in case of diamond shaped hierarchy in multiple inheritance, the super method is used.  For example:&lt;br /&gt;
&lt;br /&gt;
 Class ResponseTime():&lt;br /&gt;
  def __init__(self,time):&lt;br /&gt;
   self.time=time&amp;lt;br/&amp;gt; Class RamResponseTime(ResponseTime):&lt;br /&gt;
  def __init__(self,time);&lt;br /&gt;
   print ”RAM ResponseTime”&lt;br /&gt;
   super().__init__ (self,time)&amp;lt;br/&amp;gt; Class CacheResponseTime(ResponseTime):&lt;br /&gt;
  def __init__(self,time):&lt;br /&gt;
   print ”CacheResponseTime”&lt;br /&gt;
   super().__init__ (self,time)&amp;lt;br/&amp;gt; Class RegisterResponseTime (RamResponseTime, CacheResponseTime)&lt;br /&gt;
  def __init__(self,time):&lt;br /&gt;
   print “RegisterResponseTime”&lt;br /&gt;
   super().__init__ (self,time)&lt;br /&gt;
&lt;br /&gt;
If we had called the __init__ method on Class names instead of super method then the ResponseTime’s __init__  method would have been called twice. The use ofthe super keyword ensures that the super class’s method is called only one in case of multiple inheritance in diamond shaped graphs&lt;br /&gt;
&lt;br /&gt;
==Re- implantation of methods in Perl==&lt;br /&gt;
Unlike many other OO languages, Perl does not have any special syntax for defining class. Instead, a class can be simply described as a package that acts as a namespace for variables and methods contained in that package. Since a package does not behave like a conventional class the methods inside the class may or may not expect an object or class reference as the first argument.&lt;br /&gt;
Each class (or package as we said) contains a @ISA array. This array is required to store the package name (of type string) of all those classes that have been inherited by that class. Inheritance of methods in Perl is a built-in feature but in order to inherit attributes, explicit code needs to be written inside the class inheriting attributes from another class. So, when a class has been inherited by a subclass, all the methods from the parent’s package are implicitly available to the subclass.&lt;br /&gt;
&lt;br /&gt;
 package Fruit::Apple;&lt;br /&gt;
 use parent 'Fruit'; # sets @Fruit::Apple::ISA = ('Fruit');&lt;br /&gt;
 my $apple = Fruit::Apple-&amp;gt;new( 'GreenApple', $data );&lt;br /&gt;
 $apple-&amp;gt;save();&lt;br /&gt;
&lt;br /&gt;
The Fruit::Apple class doesn’t have a save() method defined in it. So Perl tries to find the save() method in the parent class for Fruit::Apple, that is the Fruit class. If the Fruit class also didn’t have the save() method, Perl dies. In this case, although the method save() of the Fruit class is being called, the object saved will be that of the fruit::Apple object.&lt;br /&gt;
&lt;br /&gt;
===Method Overriding===&lt;br /&gt;
Within the subclass, we can override the methods of the parent class. When calling the method from an object reference of the subclass, the implementation inside the subclass will be executed. We can also execute the implementation of any parent class method inside the subclass using the Super keyword. With this keyword, any method from the parent class can be called inside the subclass but this does not hold for subroutine calls and class methods. SUPER is a pseudo class, so methods of the parent class cannot be called as the methods of the SUPER class.&lt;br /&gt;
 &lt;br /&gt;
 SUPER::save($data); # FAIL: looks for save() sub in package SUPER&lt;br /&gt;
 SUPER-&amp;gt;save($data); # FAIL: looks for save() method in class # SUPER&lt;br /&gt;
 $thing-&amp;gt;SUPER::save(); # Okay: looks for save() method in parent# classes&lt;br /&gt;
&lt;br /&gt;
====Super Keyword====&lt;br /&gt;
In a multi-level hierarchy, the super keyword is resolved not on the basis of the object’s class but on the basis of the package inside which it is being called. This allows classes in a multi-level hierarchy to call its immediate parent’s method using the super keyword.&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
 package A;&lt;br /&gt;
 sub new {&lt;br /&gt;
 return bless {}, shift;&lt;br /&gt;
 }&lt;br /&gt;
 sub speak {&lt;br /&gt;
 my $self = shift;&lt;br /&gt;
 $self-&amp;gt;SUPER::speak();&lt;br /&gt;
 say 'A';&lt;br /&gt;
 }&amp;lt;br/&amp;gt;package B;&lt;br /&gt;
 use parent 'A';&lt;br /&gt;
 sub speak {&lt;br /&gt;
 my $self = shift;&lt;br /&gt;
 $self-&amp;gt;SUPER::speak();&lt;br /&gt;
 say 'B';&lt;br /&gt;
 }&amp;lt;br/&amp;gt;package C;&lt;br /&gt;
 use parent 'B';&lt;br /&gt;
 sub speak {&lt;br /&gt;
 my $self = shift;&lt;br /&gt;
 $self-&amp;gt;SUPER::speak();&lt;br /&gt;
 say 'C';&lt;br /&gt;
 }&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;my $c = C-&amp;gt;new();&amp;lt;br/&amp;gt;$c-&amp;gt;speak();&lt;br /&gt;
&lt;br /&gt;
Output:&amp;lt;br/&amp;gt;&lt;br /&gt;
A  //Method speak() from package A will complete execution first&amp;lt;br/&amp;gt;B // Followed by the speak() method from package B&amp;lt;br/&amp;gt;C //And lastly the method speak() from package C will finish execution&lt;br /&gt;
&lt;br /&gt;
===Multiple Inheritance===&lt;br /&gt;
Though multiple inheritance is bound to raise design issues, nevertheless it provides a convenient mechanism for code reuse and implementation. Perl supports multiple inheritance with a complicated method lookup mechanism.&lt;br /&gt;
When a class is inheriting multiple classes, then the names of all the classes will go inside the @ISA array. &lt;br /&gt;
When resolving method names, Perl will search for the method in the following order and stops as soon as it finds an implementation:&lt;br /&gt;
1.Inside the class on which the method call has been made.&lt;br /&gt;
2.The first class in the @ISA array and if not found it will go up to the inheritance hierarchy for this class until it finds the method.&lt;br /&gt;
3.The second class in the @ISA array and if not found it will go up to the inheritance hierarchy for this class until it finds the method.&lt;br /&gt;
4.The third class in the @ISA array and so on…&lt;br /&gt;
So Perl will lookup into the inheritance hierarchy of each of the classes in the @ISA array in a depth-first search from left to right manner. In doing so, it may happen, that a grand-parent class is visited before its child class as can be understood from the following diagram.&lt;br /&gt;
&amp;lt;br/&amp;gt;[[File:perldiagram.jpg]]&amp;lt;br/&amp;gt;&lt;br /&gt;
When calling a method on the Child class, it will be resolved in the order – Child, Parent 1, Granparent 1, Parent 2, Grandparent 2. This might be a problem as we are checking Grandparent 1 before checking all of its subclasses down the hierarchy. This problem can be solved by using the C3 resolution from the mro pragma. The c3 resolution order ensures that all the classes of a parent class are searched before the parent class itself. So the order of resolution will be – Child, Parent 1, Parent 2, Grandparent 1, Grandparent 2. The resolution is no more depth-first search now.&lt;br /&gt;
&lt;br /&gt;
 package Child;&lt;br /&gt;
 use mro 'c3';&lt;br /&gt;
 use parent 'Parent1', 'Parent2';&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Methods are re implemented in inherited classes to provide custom implementation of methods in Derived Classes as well as to utilize some of the predefined functionalities in Super classes. This approach has been demonstrated in PHP, Objective-C, Python, Perl along with relevant examples and also some of the related mechanisms have been demonstrated. These examples show that method re-implementation is achieved differently in different OO languages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
*[1]: http://php.net/manual/en/language.oop5.inheritance.php&lt;br /&gt;
*[2]: http://phpti.com/&lt;br /&gt;
*[3]: http://perl.active-venture.com/pod/perltoot-inheritance.html&lt;br /&gt;
*[4]: http://www.tutorialspoint.com/perl/perl_oo_perl.htm&lt;br /&gt;
*[5]: http://perldoc.perl.org/perlobj.html&lt;br /&gt;
*[6]: http://www.otierney.net/objective-c.html&lt;br /&gt;
*[7]: http://proquestcombo.safaribooksonline.com.prox.lib.ncsu.edu/book/programming/objective-c/9780132900904&lt;br /&gt;
*[8]: http://site.ebrary.com.prox.lib.ncsu.edu/lib/ncsu/docDetail.action?docID=10518920&lt;br /&gt;
*[9]: http://docs.python.org/reference&lt;br /&gt;
*[10]: http://proquestcombo.safaribooksonline.com.prox.lib.ncsu.edu/9780768687040&lt;br /&gt;
*[11]: http://proquestcombo.safaribooksonline.com.prox.lib.ncsu.edu/book/programming/python/0596100469&lt;br /&gt;
*[12]: http://www.python.org/download/releases/2.3/mro/&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w34_vd&amp;diff=65197</id>
		<title>CSC/ECE 517 Fall 2012/ch1 1w34 vd</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch1_1w34_vd&amp;diff=65197"/>
		<updated>2012-09-19T16:28:39Z</updated>

		<summary type="html">&lt;p&gt;Vkhuran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Object oriented languages support inheritance through different mechanisms. Methods from parent classes can be re-implemented in child classes to improve the behavior of the child class without having to re-write the whole class or define a completely new method. As method re-implementation in descendant classes is achieved differently in different classes it is crucial to understand these mechanisms.&lt;br /&gt;
&lt;br /&gt;
==Re- implantation of methods in PHP 5==&lt;br /&gt;
The object model in PHP5 was rewritten to include OO features such as final, abstract and visibility for classes and methods and improve the overall performance of the language. Re-implantation of methods in PHP 5 can be achieved in the following manner:&lt;br /&gt;
&lt;br /&gt;
===Object Inheritance===&lt;br /&gt;
This is an important OO feature that PHP uses in its object model. When a subclass extends from a parent class, it inherits all the public and protected methods from the parent class. The issues that affect how the inherited methods behave are:&lt;br /&gt;
&lt;br /&gt;
====Method Visibility====&lt;br /&gt;
All methods that are defined as ‘public’ and ‘protected’ in the parent class are ‘visible’ in the subclass. Public and protected are access modifiers that define the visibility of methods between different classes. Methods defined as ‘private’ access are not visible in the subclass. Methods declared without any access keyword are ‘public’.&lt;br /&gt;
&amp;lt;br/&amp;gt;Example:&lt;br /&gt;
 &amp;lt;?php &lt;br /&gt;
 class GameClass&lt;br /&gt;
 { &lt;br /&gt;
  public function_construct(){ } //Declare a public constructor &amp;lt;br/&amp;gt; public function GamePublic(){ } //Declare a public method&amp;lt;br/&amp;gt;protected function GameProtected(){ } //Declare a protected method&amp;lt;br/&amp;gt;private function GamePrivate(){ }  //Declare a private method&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;function Play()  //This is public&amp;lt;br/&amp;gt;{&lt;br /&gt;
  $this-&amp;gt;GamePublic();&lt;br /&gt;
 $this-&amp;gt;GameProtected();&lt;br /&gt;
 $this-&amp;gt;GamePrivate(); &lt;br /&gt;
 } &lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 $mygame = new GameClass;&amp;lt;br/&amp;gt;$mygame-&amp;gt;GamePublic(); // Works&amp;lt;br/&amp;gt;$mygame-&amp;gt;GameProtected(); // Fatal Error&amp;lt;br/&amp;gt;$mygame-&amp;gt;GamePrivate(); // Fatal Error&amp;lt;br/&amp;gt;$mygame-&amp;gt;Play(); // Public, Protected and Private work   &amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;class BoardGame extends GameClass &lt;br /&gt;
 {&amp;lt;br/&amp;gt;//This is public&amp;lt;br/&amp;gt; function PlayDice()&amp;lt;br/&amp;gt;{ &amp;lt;br/&amp;gt;$this-&amp;gt;GamePublic();&amp;lt;br/&amp;gt; $this-&amp;gt;GameProtected();&amp;lt;br/&amp;gt; $this-&amp;gt;GamePrivate(); // Fatal Error &amp;lt;br/&amp;gt; } &amp;lt;br/&amp;gt;}&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;$myboard = new BoardGame;&amp;lt;br/&amp;gt;$myboard-&amp;gt;GamePublic(); // Works &amp;lt;br/&amp;gt;$myboard-&amp;gt;PlayDice(); // Public and Protected work, not Private &lt;br /&gt;
&lt;br /&gt;
====Overriding====&lt;br /&gt;
If a subclass defines a new method with the same name and signature as that of the method from the parent class then an object of the subclass calling that method will execute the implementation of the method defined in the subclass.&lt;br /&gt;
Example: change this example of overriding&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class game&lt;br /&gt;
 {&lt;br /&gt;
 public function game-name($string)&lt;br /&gt;
  {&lt;br /&gt;
  echo 'Game: ' . $string . PHP_EOL;&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
 public function play()&lt;br /&gt;
  {&lt;br /&gt;
  echo 'I like this game.' . PHP_EOL;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 class chess-game extends game&lt;br /&gt;
 {&lt;br /&gt;
  public function game-name($string)&lt;br /&gt;
  {&lt;br /&gt;
  echo 'Board Game: ' . $string . PHP_EOL;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 $gm = new game ();&lt;br /&gt;
 $cg = new chess-game();&lt;br /&gt;
 $game-&amp;gt;game-name('cricket'); // Output: 'Game: cricket'&lt;br /&gt;
 $gm-&amp;gt;play();       // Output: 'I like this game' &lt;br /&gt;
 $cg-&amp;gt;game-name('chess'); // Output: 'Board Game: chess'&lt;br /&gt;
 $cg-&amp;gt;play();       // Output: 'I like this game'&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
====Scope Resolution====&lt;br /&gt;
When a subclass extends a class, then the overridden and overloaded methods of the parent class can be called, using the scope resolution operator (::) inside the subclass.&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class ParentClass&lt;br /&gt;
 {&lt;br /&gt;
 protected function parentFunc()&lt;br /&gt;
  {&lt;br /&gt;
  echo &amp;quot;ParentClass::parentFunc()\n&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 class ChildClass extends ParentClass&lt;br /&gt;
 {&lt;br /&gt;
 // Override parent's definition&lt;br /&gt;
 public function parentFunc()&lt;br /&gt;
  {&lt;br /&gt;
  // Call the parent function&lt;br /&gt;
  parent::parentFunc();&lt;br /&gt;
  echo &amp;quot;ChildClass::parentFunc()\n&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 $class = new ChildClass();&lt;br /&gt;
 $class-&amp;gt;parentFunc();&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 Output&lt;br /&gt;
 ParentClass::parentFunc()&lt;br /&gt;
 ChildClass::parentFunc()&lt;br /&gt;
&lt;br /&gt;
===Class Abstraction===&lt;br /&gt;
&lt;br /&gt;
Abstract methods in PHP 5 are methods inside abstract class that only provide signature for the method without any actual implementation to it. An abstract method has an abstract keyword at the beginning of the method declaration. A class containing even a single abstract method should be declared as abstract by adding the abstract keyword to its declaration. Any class inheriting from an abstract class should provide implementation of all of the abstract methods or declare it abstract. No class can inherit from more than one abstract class. The inheriting class, should have the same signature for the inherited abstract methods and the same or less restrictive visibility as defined in the methods in the abstract class.&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 abstract class ParentAbstractClass&lt;br /&gt;
 {&lt;br /&gt;
  // Method without definition&lt;br /&gt;
  abstract protected function getName();&lt;br /&gt;
  abstract protected function setName($name);&lt;br /&gt;
  // Method with definition&lt;br /&gt;
  public function printName()&lt;br /&gt;
  {&lt;br /&gt;
   print $this-&amp;gt;getName() . &amp;quot;\n&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 class ConcreteChild extends ParentAbstractClass&lt;br /&gt;
 {&lt;br /&gt;
  //Method from abstract class implemeted&lt;br /&gt;
  protected function getName() &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
  //Method from abstract class implemeted&lt;br /&gt;
  public function setName($name) &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild : {$name}&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 class ConcreteChild2 extends ParentAbstractClass&lt;br /&gt;
 {&lt;br /&gt;
 //Method from abstract class implemeted&lt;br /&gt;
  public function getname() &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild2&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 //Method from abstract class implemeted&lt;br /&gt;
  public function setName($name) &lt;br /&gt;
  {&lt;br /&gt;
   return &amp;quot;ConcreteChild2 : {$name}&amp;quot;;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 $class1 = new ConcreteChild;&lt;br /&gt;
 $class1-&amp;gt;printName();&lt;br /&gt;
 echo $class1-&amp;gt;setName('FOO') .&amp;quot;\n&amp;quot;;&lt;br /&gt;
 $class2 = new ConcreteChild2;&lt;br /&gt;
 $class2-&amp;gt;printName();&lt;br /&gt;
 echo $class2-&amp;gt;setName('FOO') .&amp;quot;\n&amp;quot;;&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 The above example will output:&lt;br /&gt;
 ConcreteChild&lt;br /&gt;
 ConcreteChild : FOO&lt;br /&gt;
 ConcreteChild2&lt;br /&gt;
 ConcreteChild2 : FOO&lt;br /&gt;
&lt;br /&gt;
===Object Interfaces===&lt;br /&gt;
Interface in PHP is a mechanism that specifies methods that a class requires to implement, without having to provide any implementation to these methods inside the interface. An interface is declared like any other class, just that it is prefixed by the interface keyword and none of its methods have any content to them. A class providing implementation of the methods of an interface has the implements keyword followed by the class name for that class.&lt;br /&gt;
Similarly, an interface can be inherited by another interface so that, a class implementing the interface that is lowest in the inheritance hierarchy gets to implement the methods from all the interfaces.&lt;br /&gt;
Methods inside the interface being implemented by a class should have the same signature as that of the interface.&lt;br /&gt;
Note: An interface cannot be instantiated.&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 interface food&lt;br /&gt;
 {&lt;br /&gt;
 //Interface method with no implementation&lt;br /&gt;
  public function eat();&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;br/&amp;gt;interface fruit&lt;br /&gt;
 {&lt;br /&gt;
 //Interface method with no implementation&lt;br /&gt;
  public function fruitName();&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;br/&amp;gt;interface Apple extends food, fruit&lt;br /&gt;
 {&lt;br /&gt;
 //Interface method with no implementation&lt;br /&gt;
  public function juice();&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;br/&amp;gt;class GreenApple implements Apple&lt;br /&gt;
 {&lt;br /&gt;
 //Implementing methods from all the interfaces&lt;br /&gt;
 public function eat()&lt;br /&gt;
  {&lt;br /&gt;
  echo “Food: eat()”;&lt;br /&gt;
  }&lt;br /&gt;
 public function fruitName()&lt;br /&gt;
  {&lt;br /&gt;
  echo “Fruit: fruitName()”;&lt;br /&gt;
  }&lt;br /&gt;
 public function juice()&lt;br /&gt;
  {&lt;br /&gt;
  echo “Apple: juice()”;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class GreenApple will implement all the methods that it has inherited from all the interfaces in inheritance hierarchy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Objective-C==&lt;br /&gt;
In Objective-C the method declaration is done in the ‘@interface’ section and the method definitions are provided in the ‘@implementation’ section and these two are stored in different files.  &lt;br /&gt;
There are two types of methods in Objective C – &lt;br /&gt;
&amp;lt;br/&amp;gt;1.Instance Methods: Instance methods are denoted by placing a (-) sign before them while declaring them and are used to access and modify the instance variables over a particular instance of a class.&lt;br /&gt;
&lt;br /&gt;
2.Class Methods: Class Methods do not require an object of the Class to be created in order to be called upon. These are very similar to ‘Static’ methods in JAVA. They are denoted by putting a (+) sign before the method name while declaring them. &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
 myPizza = [Pizza new];	//new is a Class method on Pizza Class &lt;br /&gt;
 [mypizza setcost]	//setcost is an instance method called on the particular instance ‘mypizza’&lt;br /&gt;
&lt;br /&gt;
===Method Overriding===&lt;br /&gt;
Objective-C does not support multiple inheritance and method overloading. However it supports single inheritance and methods can be overridden to re-implement the instance methods in subclasses. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Patient.h class&lt;br /&gt;
 //Interface for Superclass. Here we declare methods and variables&amp;lt;br/&amp;gt;@interface Patient: NSObject 			/*NSObject is the root object and Patient inherits from NSObject*/&lt;br /&gt;
  {						     	&lt;br /&gt;
   int patient_number;				//attributes of patient class              &lt;br /&gt;
   char sex;&lt;br /&gt;
  }&lt;br /&gt;
  @property int patient_number, char sex;&lt;br /&gt;
  -(int) return_patient_number;&lt;br /&gt;
  -(char) return_sex;				/*method declarations for superclass specifying the return type and arguments*/  &lt;br /&gt;
  -(void) setDetails: (int)number : (char)s;		     &lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Patient.m class&lt;br /&gt;
 //Implemetation for Superclass. Here we define methods to modify instance variables&amp;lt;br/&amp;gt;#import  “Patient.h”			//importing interface class&lt;br /&gt;
 @implementation Patient&lt;br /&gt;
  @synthesize patient_number, sex;		//synthesizing instance variables&lt;br /&gt;
  -(void) setDetails : (int)number : (char)s    //method definitions&lt;br /&gt;
    {&lt;br /&gt;
     patient_number=number;&lt;br /&gt;
     sex=s;&lt;br /&gt;
    } &lt;br /&gt;
  -(int) return_patient_number&lt;br /&gt;
    {&lt;br /&gt;
     return patient_number&lt;br /&gt;
    }&lt;br /&gt;
  -(char)return_sex    &lt;br /&gt;
    {&lt;br /&gt;
     return sex&lt;br /&gt;
    }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Now we define a new class that inherits Patient Class&amp;lt;br/&amp;gt;Diabetic.h&lt;br /&gt;
 //interface for the subclass. Here we declare methods for the subclass&amp;lt;br/&amp;gt;#import “Patient.h”		       //importing Superclass’s interface&lt;br /&gt;
 @interface Diabetic : Patient&lt;br /&gt;
  {&lt;br /&gt;
   int blood_sugar;		//additional attribute for the subclass&lt;br /&gt;
  }&lt;br /&gt;
  @property int blood_sugar;&lt;br /&gt;
  -(void) setDetails: (int)number : (char)s : (int)sugar;		//method declarations&lt;br /&gt;
  -(int) return_blood_sugar;&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Diabetic.m&lt;br /&gt;
 //implementation for the subclass&amp;lt;br/&amp;gt;#import “Diabetic.h”			//Subclass importing its own interface&lt;br /&gt;
 @implementation Diabetic: Patient&lt;br /&gt;
  @synthesize blood_sugar;&lt;br /&gt;
  -(void) setDetails: (int)number : (char)s : (int)sugar	//Method Overriding&lt;br /&gt;
   {&lt;br /&gt;
    patient_number=number;&lt;br /&gt;
    sex=s;&lt;br /&gt;
    blood_sugar=sugar;&lt;br /&gt;
   }&lt;br /&gt;
  -(int) return_blood_sugar&lt;br /&gt;
   {&lt;br /&gt;
    return blood_sugar; &lt;br /&gt;
   }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
 //Test program to run the code&amp;lt;br/&amp;gt;# import “Diabetic.h”&lt;br /&gt;
 int main( int argc, char *argv[])&lt;br /&gt;
  {&lt;br /&gt;
   NSAutoreleasepool *pool = [[NSAutoreleasePool alloc] init];&lt;br /&gt;
   Diabetic *dia=[[Diabetic alloc] init];&lt;br /&gt;
   [dia setDetails: 10 :’M’ :500];		&lt;br /&gt;
   NSLog( @”Patient number is %i ,Patient Sex is %c, Patient sugar level is %i”, [dia return_patient_number], [dia return_sex ],[dia return_blood_sugar]);&lt;br /&gt;
   [dia release];&lt;br /&gt;
   return 0;&lt;br /&gt;
  }&lt;br /&gt;
Output would be:&lt;br /&gt;
Patient number is 10 ,Patient Sex is M, Patient sugar level is 100&lt;br /&gt;
&lt;br /&gt;
===Abstract Classes===&lt;br /&gt;
Abstract Classes are provided to the users to give them a common interface to interact with the objects.&lt;br /&gt;
There is no access specifier for abstract classes in Objective-C. Users cannot generate pure abstract classes. However a number of abstract classes have been provided to the users. For Example: NSObject in the above example is an abstract class. It cannot be instantiated by the user but is the root class of every class in Objective C.&lt;br /&gt;
&lt;br /&gt;
===Protocols===&lt;br /&gt;
A protocol is similar to Interfaces in JAVA. It specifies a set of behavior/methods that the object who conforms to that protocol must implement. A protocol is defined by using a @protocol directive before the name of the protocol. &lt;br /&gt;
For example:&lt;br /&gt;
 @protocol Alive&lt;br /&gt;
  {&lt;br /&gt;
   : (void) sleep;&lt;br /&gt;
   : (void) eat; &lt;br /&gt;
  }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
If a Class Human conforms to this protocol then it must implement both the methods in it’s implementation section. However it need not declare these methods.&lt;br /&gt;
&lt;br /&gt;
 @ interface Human: NSObject &amp;lt;Alive&amp;gt;&lt;br /&gt;
  {&lt;br /&gt;
  }&lt;br /&gt;
 @end&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;#import  “Human.h”			&lt;br /&gt;
 @implementation Human		&lt;br /&gt;
  -(void) sleep		&lt;br /&gt;
  {&lt;br /&gt;
   NSLog(@”I Sleep”);&lt;br /&gt;
  } &lt;br /&gt;
  -(void) eat&lt;br /&gt;
   {&lt;br /&gt;
    NSLog(@”I Eat”);&lt;br /&gt;
   }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
===Categories===&lt;br /&gt;
Categories provide a mechanism to enhance the functionality of a class without subclassing it. You can add new methods to an existing class and also utilize the methods in the existing class by the use of categories. For example:&lt;br /&gt;
&lt;br /&gt;
 @interface Alive: NSObject&lt;br /&gt;
  {&lt;br /&gt;
   : (void) sleep;&lt;br /&gt;
   : (void) eat; &lt;br /&gt;
  }&lt;br /&gt;
 @end&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;#import  ”Alive.h”&lt;br /&gt;
 @interface Alive(OnLiquidDiet)&lt;br /&gt;
  {&lt;br /&gt;
   : (void) sleep;&lt;br /&gt;
   : (void) drinks;&lt;br /&gt;
  }&lt;br /&gt;
 @end&lt;br /&gt;
&lt;br /&gt;
Here we have defined a new Category ‘OnLiquidDiet’ for the Alive Class which has a different method ‘drinks’ other than the ‘sleep’ method in the Alive Class.&lt;br /&gt;
Although categories can be used for overriding methods, it is not recommended because you cannot access the original method definition once it is overridden in a category. In the above example if we override the ‘sleep’ method in the ‘OnLiquidDiet’ category we won’t be able to access the original ‘sleep’ method from the category.&lt;br /&gt;
&lt;br /&gt;
==Re-implementation of Methods in Python==&lt;br /&gt;
&lt;br /&gt;
Methods can be re-implemented using inheritance in Python, but unlike Objective-C it supports multiple inheritance. However it does not support method overloading.&lt;br /&gt;
In order to implement inheritance the names of the super class separated by commas are defined in the class statement.The Object class is the default base class of all the classes in Python.&lt;br /&gt;
A sample example to show re-implementation of method in the subclass is shown below:&lt;br /&gt;
 class Patient(object):&lt;br /&gt;
  def  __init__(self,patient_number,age,weight):&lt;br /&gt;
   self.patient_number=patient_number&lt;br /&gt;
   self.age=age&lt;br /&gt;
   self.weight=weight&lt;br /&gt;
  def displayDetails(self):&lt;br /&gt;
   return “Patient’s name:” +str(self.patient_number)+ “Patient’s age”+str( self.age),+ “Patient’s weight”+str(self.weight)&lt;br /&gt;
&lt;br /&gt;
Now we define another class that inherits from the Patient Class&lt;br /&gt;
 Class Diabetic (Patient):&lt;br /&gt;
  def __init__(self,patient_ number,age,weight,blood_sugar):&lt;br /&gt;
   super.__init__(patient_ number,age,weight)&lt;br /&gt;
   self.blood_sugar=blood_sugar&lt;br /&gt;
  def displayDetails(self):&lt;br /&gt;
   return super. displayDetails(self)+” Blood Sugar:” + str(self.blood_sugar)&lt;br /&gt;
&lt;br /&gt;
This example typically represents a single inheritance. The Diabetic class overrides the’ __init__’ and ‘displayDetails’ method and in each method a super method call is invoked in order to call the superclass method. If any of these methods were not defined in the subclass and a method call had been invoked on the object of the subclass for that method, then the superclass’s method would have been invoked.&lt;br /&gt;
&lt;br /&gt;
===Abstract Base Classes===&lt;br /&gt;
&lt;br /&gt;
An Abstract Base Class is similar to Interfaces in JAVA and complement duck typing in Python by defining that the class would conform to a given behavior. An abstract class cannot be instantiated and any class that registers to the abstract class must define the abstract methods of the abstract class, though it may choose not to re-implement the methods that had already been defined in the abstract class. The abc module is used for defining an abstract base class. An example to define an abstract class is shown below:&lt;br /&gt;
&lt;br /&gt;
 import abc&lt;br /&gt;
 class PaintBuilding(object):&lt;br /&gt;
  __metaclass__= abc.ABCMeta&lt;br /&gt;
  @abc.abstractmethod&lt;br /&gt;
  def contour():&lt;br /&gt;
   pass&amp;lt;br/&amp;gt;def color():&lt;br /&gt;
   return ”Paint with Red and Blue”&lt;br /&gt;
&lt;br /&gt;
A class needs to register with the Abstract Base Class in order to use it.&lt;br /&gt;
&lt;br /&gt;
 import abc&lt;br /&gt;
 from packageA import PaintBuilding&lt;br /&gt;
 Class PaintRectangularBuilding(object):&lt;br /&gt;
  def contour():&lt;br /&gt;
   return ”Building is Rectangular” &lt;br /&gt;
  def color():&lt;br /&gt;
   return “Paint the Rectangular building Red and Blue”&amp;lt;br/&amp;gt;PaintBuilding.register(PaintRectangularBuilding)&lt;br /&gt;
&lt;br /&gt;
===Multiple Inheritance===&lt;br /&gt;
Since Multiple Inheritance is supported in Python, we can define several classes separated by commas in the class statement. For example:&lt;br /&gt;
 Class Amphibian(LandAnimal,MarineAnimal):&lt;br /&gt;
Since multiple inheritance is prone to conflicts, there is something defined as the Method Resolution Order (MRO) that specifies the sequence in which the method or attribute is looked up in the various super classes. If there is no multiple inheritance then the lookup is done in left to right, depth first order when a particular method on the subclass object is called upon that is not defined in the subclass. However, this approach leads to the same parent being visited more than once if a diamond shaped hierarchy is obtained in case of multiple inheritance. To resolve the conflicts in such cases a new-style MRO has been defined that essentially considers only the rightmost occurrence of any super class and neglects the other occurrences. &lt;br /&gt;
Use of Super keyword&lt;br /&gt;
In Python 3 the super method can be used without any arguments, though the old version of it with arguments is also supported. In order to prevent the same method in the super class being looked up twice in case of diamond shaped hierarchy in multiple inheritance, the super method is used.  For example:&lt;br /&gt;
&lt;br /&gt;
 Class ResponseTime():&lt;br /&gt;
  def __init__(self,time):&lt;br /&gt;
   self.time=time&amp;lt;br/&amp;gt; Class RamResponseTime(ResponseTime):&lt;br /&gt;
  def __init__(self,time);&lt;br /&gt;
   print ”RAM ResponseTime”&lt;br /&gt;
   super().__init__ (self,time)&amp;lt;br/&amp;gt; Class CacheResponseTime(ResponseTime):&lt;br /&gt;
  def __init__(self,time):&lt;br /&gt;
   print ”CacheResponseTime”&lt;br /&gt;
   super().__init__ (self,time)&amp;lt;br/&amp;gt; Class RegisterResponseTime (RamResponseTime, CacheResponseTime)&lt;br /&gt;
  def __init__(self,time):&lt;br /&gt;
   print “RegisterResponseTime”&lt;br /&gt;
   super().__init__ (self,time)&lt;br /&gt;
&lt;br /&gt;
If we had called the __init__ method on Class names instead of super method then the ResponseTime’s __init__  method would have been called twice. The use ofthe super keyword ensures that the super class’s method is called only one in case of multiple inheritance in diamond shaped graphs&lt;br /&gt;
&lt;br /&gt;
==Re- implantation of methods in Perl==&lt;br /&gt;
Unlike many other OO languages, Perl does not have any special syntax for defining class. Instead, a class can be simply described as a package that acts as a namespace for variables and methods contained in that package. Since a package does not behave like a conventional class the methods inside the class may or may not expect an object or class reference as the first argument.&lt;br /&gt;
Each class (or package as we said) contains a @ISA array. This array is required to store the package name (of type string) of all those classes that have been inherited by that class. Inheritance of methods in Perl is a built-in feature but in order to inherit attributes, explicit code needs to be written inside the class inheriting attributes from another class. So, when a class has been inherited by a subclass, all the methods from the parent’s package are implicitly available to the subclass.&lt;br /&gt;
&lt;br /&gt;
 package Fruit::Apple;&lt;br /&gt;
 use parent 'Fruit'; # sets @Fruit::Apple::ISA = ('Fruit');&lt;br /&gt;
 my $apple = Fruit::Apple-&amp;gt;new( 'GreenApple', $data );&lt;br /&gt;
 $apple-&amp;gt;save();&lt;br /&gt;
&lt;br /&gt;
The Fruit::Apple class doesn’t have a save() method defined in it. So Perl tries to find the save() method in the parent class for Fruit::Apple, that is the Fruit class. If the Fruit class also didn’t have the save() method, Perl dies. In this case, although the method save() of the Fruit class is being called, the object saved will be that of the fruit::Apple object.&lt;br /&gt;
&lt;br /&gt;
===Method Overriding===&lt;br /&gt;
Within the subclass, we can override the methods of the parent class. When calling the method from an object reference of the subclass, the implementation inside the subclass will be executed. We can also execute the implementation of any parent class method inside the subclass using the Super keyword. With this keyword, any method from the parent class can be called inside the subclass but this does not hold for subroutine calls and class methods. SUPER is a pseudo class, so methods of the parent class cannot be called as the methods of the SUPER class.&lt;br /&gt;
 &lt;br /&gt;
 SUPER::save($data); # FAIL: looks for save() sub in package SUPER&lt;br /&gt;
 SUPER-&amp;gt;save($data); # FAIL: looks for save() method in class # SUPER&lt;br /&gt;
 $thing-&amp;gt;SUPER::save(); # Okay: looks for save() method in parent# classes&lt;br /&gt;
&lt;br /&gt;
====Super Keyword====&lt;br /&gt;
In a multi-level hierarchy, the super keyword is resolved not on the basis of the object’s class but on the basis of the package inside which it is being called. This allows classes in a multi-level hierarchy to call its immediate parent’s method using the super keyword.&lt;br /&gt;
Example&lt;br /&gt;
&lt;br /&gt;
 package A;&lt;br /&gt;
 sub new {&lt;br /&gt;
 return bless {}, shift;&lt;br /&gt;
 }&lt;br /&gt;
 sub speak {&lt;br /&gt;
 my $self = shift;&lt;br /&gt;
 $self-&amp;gt;SUPER::speak();&lt;br /&gt;
 say 'A';&lt;br /&gt;
 }&amp;lt;br/&amp;gt;package B;&lt;br /&gt;
 use parent 'A';&lt;br /&gt;
 sub speak {&lt;br /&gt;
 my $self = shift;&lt;br /&gt;
 $self-&amp;gt;SUPER::speak();&lt;br /&gt;
 say 'B';&lt;br /&gt;
 }&amp;lt;br/&amp;gt;package C;&lt;br /&gt;
 use parent 'B';&lt;br /&gt;
 sub speak {&lt;br /&gt;
 my $self = shift;&lt;br /&gt;
 $self-&amp;gt;SUPER::speak();&lt;br /&gt;
 say 'C';&lt;br /&gt;
 }&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;my $c = C-&amp;gt;new();&amp;lt;br/&amp;gt;$c-&amp;gt;speak();&lt;br /&gt;
&lt;br /&gt;
Output:&amp;lt;br/&amp;gt;&lt;br /&gt;
A  //Method speak() from package A will complete execution first&amp;lt;br/&amp;gt;B // Followed by the speak() method from package B&amp;lt;br/&amp;gt;C //And lastly the method speak() from package C will finish execution&lt;br /&gt;
&lt;br /&gt;
===Multiple Inheritance===&lt;br /&gt;
Though multiple inheritance is bound to raise design issues, nevertheless it provides a convenient mechanism for code reuse and implementation. Perl supports multiple inheritance with a complicated method lookup mechanism.&lt;br /&gt;
When a class is inheriting multiple classes, then the names of all the classes will go inside the @ISA array. &lt;br /&gt;
When resolving method names, Perl will search for the method in the following order and stops as soon as it finds an implementation:&lt;br /&gt;
1.Inside the class on which the method call has been made.&lt;br /&gt;
2.The first class in the @ISA array and if not found it will go up to the inheritance hierarchy for this class until it finds the method.&lt;br /&gt;
3.The second class in the @ISA array and if not found it will go up to the inheritance hierarchy for this class until it finds the method.&lt;br /&gt;
4.The third class in the @ISA array and so on…&lt;br /&gt;
So Perl will lookup into the inheritance hierarchy of each of the classes in the @ISA array in a depth-first search from left to right manner. In doing so, it may happen, that a grand-parent class is visited before its child class as can be understood from the following diagram.&lt;br /&gt;
&amp;lt;br/&amp;gt;[[File:perldiagram.jpg]]&amp;lt;br/&amp;gt;&lt;br /&gt;
When calling a method on the Child class, it will be resolved in the order – Child, Parent 1, Granparent 1, Parent 2, Grandparent 2. This might be a problem as we are checking Grandparent 1 before checking all of its subclasses down the hierarchy. This problem can be solved by using the C3 resolution from the mro pragma. The c3 resolution order ensures that all the classes of a parent class are searched before the parent class itself. So the order of resolution will be – Child, Parent 1, Parent 2, Grandparent 1, Grandparent 2. The resolution is no more depth-first search now.&lt;br /&gt;
&lt;br /&gt;
 package Child;&lt;br /&gt;
 use mro 'c3';&lt;br /&gt;
 use parent 'Parent1', 'Parent2';&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
Methods are re implemented in inherited classes to provide custom implementation of methods in Derived Classes as well as to utilize some of the predefined functionalities in Super classes. This approach has been demonstrated in PHP, Objective-C, Python, Perl along with relevant examples and also some of the related mechanisms have been demonstrated. These examples show that method re-implementation is achieved differently in different OO languages.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
*[1]: http://php.net/manual/en/language.oop5.inheritance.php&lt;br /&gt;
*[2]: http://phpti.com/&lt;br /&gt;
*[3]: http://perl.active-venture.com/pod/perltoot-inheritance.html&lt;br /&gt;
*[4]: http://www.tutorialspoint.com/perl/perl_oo_perl.htm&lt;br /&gt;
*[5]: http://perldoc.perl.org/perlobj.html&lt;br /&gt;
*[6]: http://www.otierney.net/objective-c.html&lt;br /&gt;
*[7]: http://proquestcombo.safaribooksonline.com.prox.lib.ncsu.edu/book/programming/objective-c/9780132900904&lt;br /&gt;
*[8]: http://site.ebrary.com.prox.lib.ncsu.edu/lib/ncsu/docDetail.action?docID=10518920&lt;br /&gt;
*[9]: http://docs.python.org/reference&lt;br /&gt;
*[10]: http://proquestcombo.safaribooksonline.com.prox.lib.ncsu.edu/9780768687040&lt;br /&gt;
*[11]: http://proquestcombo.safaribooksonline.com.prox.lib.ncsu.edu/book/programming/python/0596100469&lt;br /&gt;
*[12]: http://www.python.org/download/releases/2.3/mro/&lt;/div&gt;</summary>
		<author><name>Vkhuran</name></author>
	</entry>
</feed>