<?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=Ubsingh</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=Ubsingh"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Ubsingh"/>
	<updated>2026-07-13T23:04:02Z</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_2007/wiki3_6_ub&amp;diff=9172</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9172"/>
		<updated>2007-11-19T03:46:37Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What are Design Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Patterns are simply ''proven solutions to common problems''. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GRASP Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for '''G'''eneral '''R'''esponsibility '''A'''ssignment '''S'''oftware '''P'''atterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; '''widely applicable'''&lt;br /&gt;
&lt;br /&gt;
Responsibility =&amp;gt; '''Obligations''', duties&lt;br /&gt;
&lt;br /&gt;
Assignment =&amp;gt; '''Giving a responsibility to a module'''&lt;br /&gt;
&lt;br /&gt;
Software =&amp;gt; '''Computer code'''&lt;br /&gt;
&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, '''abstractions&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
&lt;br /&gt;
Information Expert&lt;br /&gt;
&lt;br /&gt;
Creator&lt;br /&gt;
&lt;br /&gt;
Controller&lt;br /&gt;
&lt;br /&gt;
Low Coupling&lt;br /&gt;
&lt;br /&gt;
High Cohesion&lt;br /&gt;
&lt;br /&gt;
Polymorphism&lt;br /&gt;
&lt;br /&gt;
Pure Fabrication&lt;br /&gt;
&lt;br /&gt;
Indirection&lt;br /&gt;
&lt;br /&gt;
Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
&lt;br /&gt;
- '''Knowing responsibilities''' that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
&lt;br /&gt;
- '''Doing responsibilities''' include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Controller Pattern&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Controller pattern addresses the question: ''Who handles a system event''?&lt;br /&gt;
&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
&lt;br /&gt;
''If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.''&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (''facade controller'').&lt;br /&gt;
&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Facade Controller'''&lt;br /&gt;
&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case or Session Controller'''&lt;br /&gt;
&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Advantages of Controller Pattern'''&lt;br /&gt;
&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
&lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment.&lt;br /&gt;
&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
[[Image:pic1.jpg]]&lt;br /&gt;
                                                 &lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:pic2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
&lt;br /&gt;
''What first object beyond the UI layer should receive the message from the UI layer?''&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
[[Image:pic3.jpg]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 3'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;br /&gt;
&lt;br /&gt;
[[Image:pic4.jpg]]&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9170</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9170"/>
		<updated>2007-11-19T03:45:45Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
'''What are Design Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
Patterns are simply ''proven solutions to common problems''. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GRASP Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for '''G'''eneral '''R'''esponsibility '''A'''ssignment '''S'''oftware '''P'''atterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; '''widely applicable'''&lt;br /&gt;
&lt;br /&gt;
Responsibility =&amp;gt; '''Obligations''', duties&lt;br /&gt;
&lt;br /&gt;
Assignment =&amp;gt; '''Giving a responsibility to a module'''&lt;br /&gt;
&lt;br /&gt;
Software =&amp;gt; '''Computer code'''&lt;br /&gt;
&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, '''abstractions&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
&lt;br /&gt;
Information Expert&lt;br /&gt;
&lt;br /&gt;
Creator&lt;br /&gt;
&lt;br /&gt;
Controller&lt;br /&gt;
&lt;br /&gt;
Low Coupling&lt;br /&gt;
&lt;br /&gt;
High Cohesion&lt;br /&gt;
&lt;br /&gt;
Polymorphism&lt;br /&gt;
&lt;br /&gt;
Pure Fabrication&lt;br /&gt;
&lt;br /&gt;
Indirection&lt;br /&gt;
&lt;br /&gt;
Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
&lt;br /&gt;
- '''Knowing responsibilities''' that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
&lt;br /&gt;
- '''Doing responsibilities''' include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Controller Pattern&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Controller pattern addresses the question: ''Who handles a system event''?&lt;br /&gt;
&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
&lt;br /&gt;
''If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.''&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (''facade controller'').&lt;br /&gt;
&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Facade Controller'''&lt;br /&gt;
&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case or Session Controller'''&lt;br /&gt;
&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Advantages of Controller Pattern'''&lt;br /&gt;
&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
&lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment.&lt;br /&gt;
&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
[[Image:pic1.jpg]]&lt;br /&gt;
                                                 &lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:pic2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
&lt;br /&gt;
''What first object beyond the UI layer should receive the message from the UI layer?''&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
[[Image:pic3.jpg]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 3'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;br /&gt;
&lt;br /&gt;
[[Image:pic4.jpg]]&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic2.jpg&amp;diff=9169</id>
		<title>File:Pic2.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic2.jpg&amp;diff=9169"/>
		<updated>2007-11-19T03:45:00Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic1.jpg&amp;diff=9168</id>
		<title>File:Pic1.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic1.jpg&amp;diff=9168"/>
		<updated>2007-11-19T03:44:38Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic3.jpg&amp;diff=9167</id>
		<title>File:Pic3.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic3.jpg&amp;diff=9167"/>
		<updated>2007-11-19T03:44:17Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic4.jpg&amp;diff=9165</id>
		<title>File:Pic4.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Pic4.jpg&amp;diff=9165"/>
		<updated>2007-11-19T03:39:55Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9161</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9161"/>
		<updated>2007-11-19T03:23:43Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What are Design Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
Patterns are simply ''proven solutions to common problems''. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GRASP Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for '''G'''eneral '''R'''esponsibility '''A'''ssignment '''S'''oftware '''P'''atterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; '''widely applicable'''&lt;br /&gt;
&lt;br /&gt;
Responsibility =&amp;gt; '''Obligations''', duties&lt;br /&gt;
&lt;br /&gt;
Assignment =&amp;gt; '''Giving a responsibility to a module'''&lt;br /&gt;
&lt;br /&gt;
Software =&amp;gt; '''Computer code'''&lt;br /&gt;
&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, '''abstractions&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
&lt;br /&gt;
Information Expert&lt;br /&gt;
&lt;br /&gt;
Creator&lt;br /&gt;
&lt;br /&gt;
Controller&lt;br /&gt;
&lt;br /&gt;
Low Coupling&lt;br /&gt;
&lt;br /&gt;
High Cohesion&lt;br /&gt;
&lt;br /&gt;
Polymorphism&lt;br /&gt;
&lt;br /&gt;
Pure Fabrication&lt;br /&gt;
&lt;br /&gt;
Indirection&lt;br /&gt;
&lt;br /&gt;
Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
&lt;br /&gt;
- '''Knowing responsibilities''' that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
&lt;br /&gt;
- '''Doing responsibilities''' include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Controller Pattern&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Controller pattern addresses the question: ''Who handles a system event''?&lt;br /&gt;
&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
&lt;br /&gt;
''If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.''&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (''facade controller'').&lt;br /&gt;
&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Facade Controller'''&lt;br /&gt;
&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case or Session Controller'''&lt;br /&gt;
&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Advantages of Controller Pattern'''&lt;br /&gt;
&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
&lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment.&lt;br /&gt;
&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
[[Image:pic1.jpg]]&lt;br /&gt;
                                                 &lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:pic2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
&lt;br /&gt;
''What first object beyond the UI layer should receive the message from the UI layer?''&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
[[Image:pic3.jpg]]&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 3'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;br /&gt;
&lt;br /&gt;
[[Image:pic4.jpg]]&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9159</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9159"/>
		<updated>2007-11-19T03:20:04Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What are Design Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
Patterns are simply ''proven solutions to common problems''. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GRASP Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for '''G'''eneral '''R'''esponsibility '''A'''ssignment '''S'''oftware '''P'''atterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; '''widely applicable'''&lt;br /&gt;
&lt;br /&gt;
Responsibility =&amp;gt; '''Obligations''', duties&lt;br /&gt;
&lt;br /&gt;
Assignment =&amp;gt; '''Giving a responsibility to a module'''&lt;br /&gt;
&lt;br /&gt;
Software =&amp;gt; '''Computer code'''&lt;br /&gt;
&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, '''abstractions&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
&lt;br /&gt;
Information Expert&lt;br /&gt;
&lt;br /&gt;
Creator&lt;br /&gt;
&lt;br /&gt;
Controller&lt;br /&gt;
&lt;br /&gt;
Low Coupling&lt;br /&gt;
&lt;br /&gt;
High Cohesion&lt;br /&gt;
&lt;br /&gt;
Polymorphism&lt;br /&gt;
&lt;br /&gt;
Pure Fabrication&lt;br /&gt;
&lt;br /&gt;
Indirection&lt;br /&gt;
&lt;br /&gt;
Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
&lt;br /&gt;
- '''Knowing responsibilities''' that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
&lt;br /&gt;
- '''Doing responsibilities''' include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Controller Pattern&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Controller pattern addresses the question: ''Who handles a system event''?&lt;br /&gt;
&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
&lt;br /&gt;
''If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.''&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (''facade controller'').&lt;br /&gt;
&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Facade Controller'''&lt;br /&gt;
&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Use Case or Session Controller'''&lt;br /&gt;
&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Advantages of Controller Pattern'''&lt;br /&gt;
&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
&lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment.&lt;br /&gt;
&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
                                                 &lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
&lt;br /&gt;
''What first object beyond the UI layer should receive the message from the UI layer?''&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 3'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9156</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9156"/>
		<updated>2007-11-19T03:12:59Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What are Design Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
Patterns are simply ''proven solutions to common problems''. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GRASP Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for '''G'''eneral '''R'''esponsibility '''A'''ssignment '''S'''oftware '''P'''atterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; '''widely applicable'''&lt;br /&gt;
&lt;br /&gt;
Responsibility =&amp;gt; '''Obligations''', duties&lt;br /&gt;
&lt;br /&gt;
Assignment =&amp;gt; '''Giving a responsibility to a module'''&lt;br /&gt;
&lt;br /&gt;
Software =&amp;gt; '''Computer code'''&lt;br /&gt;
&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, '''abstractions&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
&lt;br /&gt;
Information Expert&lt;br /&gt;
&lt;br /&gt;
Creator&lt;br /&gt;
&lt;br /&gt;
Controller&lt;br /&gt;
&lt;br /&gt;
Low Coupling&lt;br /&gt;
&lt;br /&gt;
High Cohesion&lt;br /&gt;
&lt;br /&gt;
Polymorphism&lt;br /&gt;
&lt;br /&gt;
Pure Fabrication&lt;br /&gt;
&lt;br /&gt;
Indirection&lt;br /&gt;
&lt;br /&gt;
Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
&lt;br /&gt;
- '''Knowing responsibilities''' that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
&lt;br /&gt;
- '''Doing responsibilities''' include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Controller Pattern&lt;br /&gt;
'''&lt;br /&gt;
The Controller pattern addresses the question: ''Who handles a system event''?&lt;br /&gt;
&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
&lt;br /&gt;
''If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.''&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (''facade controller'').&lt;br /&gt;
&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
'''Facade Controller'''&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
&lt;br /&gt;
'''Use Case or Session Controller'''&lt;br /&gt;
&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
&lt;br /&gt;
'''Advantages of Controller Pattern'''&lt;br /&gt;
&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
&lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment.&lt;br /&gt;
&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
                                                 &lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
&lt;br /&gt;
''What first object beyond the UI layer should receive the message from the UI layer?''&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 3'''&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9153</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9153"/>
		<updated>2007-11-19T02:59:39Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What are Design Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
Patterns are simply ''proven solutions to common problems''. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GRASP Patterns&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for '''G'''eneral '''R'''esponsibility '''A'''ssignment '''S'''oftware '''P'''atterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; widely applicable&lt;br /&gt;
Responsibility =&amp;gt; Obligations, duties&lt;br /&gt;
Assignment =&amp;gt; Giving a responsibility to a module&lt;br /&gt;
Software =&amp;gt; Computer code&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, abstractions&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
 Information Expert&lt;br /&gt;
 Creator&lt;br /&gt;
 Controller&lt;br /&gt;
 Low Coupling&lt;br /&gt;
 High Cohesion&lt;br /&gt;
 Polymorphism&lt;br /&gt;
 Pure Fabrication&lt;br /&gt;
 Indirection&lt;br /&gt;
 Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
- Knowing responsibilities that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
- Doing responsibilities include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
'''Controller Pattern&lt;br /&gt;
'''&lt;br /&gt;
The Controller pattern addresses the question: Who handles a system event?&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (facade controller).&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
'''Facade Controller'''&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
Use Case or Session Controller&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
Advantages of Controller Pattern&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
                                                   POST&lt;br /&gt;
&lt;br /&gt;
                                                  STORE&lt;br /&gt;
                                             CASHIER    &lt;br /&gt;
                                                        &lt;br /&gt;
                                BuyItemsHandler&lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
What first object beyond the UI layer should receive the message from the UI layer?&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 3'''&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9152</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9152"/>
		<updated>2007-11-19T02:56:21Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''What are Design Patterns&lt;br /&gt;
'''&lt;br /&gt;
Patterns are simply proven solutions to common problems. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GRASP Patterns&lt;br /&gt;
'''&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for General Responsibility Assignment Software Patterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; widely applicable&lt;br /&gt;
Responsibility =&amp;gt; Obligations, duties&lt;br /&gt;
Assignment =&amp;gt; Giving a responsibility to a module&lt;br /&gt;
Software =&amp;gt; Computer code&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, abstractions&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
 Information Expert&lt;br /&gt;
 Creator&lt;br /&gt;
 Controller&lt;br /&gt;
 Low Coupling&lt;br /&gt;
 High Cohesion&lt;br /&gt;
 Polymorphism&lt;br /&gt;
 Pure Fabrication&lt;br /&gt;
 Indirection&lt;br /&gt;
 Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
- Knowing responsibilities that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
- Doing responsibilities include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
'''Controller Pattern&lt;br /&gt;
'''&lt;br /&gt;
The Controller pattern addresses the question: Who handles a system event?&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (facade controller).&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
'''Facade Controller'''&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
Use Case or Session Controller&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
Advantages of Controller Pattern&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
                                                   POST&lt;br /&gt;
&lt;br /&gt;
                                                  STORE&lt;br /&gt;
                                             CASHIER    &lt;br /&gt;
                                                        &lt;br /&gt;
                                BuyItemsHandler&lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 2'''&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
What first object beyond the UI layer should receive the message from the UI layer?&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example 3'''&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9151</id>
		<title>CSC/ECE 517 Fall 2007/wiki3 6 ub</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki3_6_ub&amp;diff=9151"/>
		<updated>2007-11-19T02:54:16Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Take the Controller pattern (which we did not cover in class) and catalog the information on it available on the Web. Find good descriptions and good, concise, understandable examples. Tell which you consider the best to present to a class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What are Design Patterns&lt;br /&gt;
&lt;br /&gt;
Patterns are simply proven solutions to common problems. A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. This is done by defining a set of rules which describes how to solve the problem at hand.&lt;br /&gt;
It is often the case that patterns are not invented but are discovered. Sometimes a pattern can be as simple as an advice from a previous designer, which helps future designers to cope with new situations.&lt;br /&gt;
A design pattern by no means is a panacea. It is not as easy as finding the right pattern and simply applying it to get the solution. The application of a pattern to a problem requires careful analysis to ensure that the pattern actually applies to the problem. It is important to make sure the pattern does not have negative side effects upon the rest of the system or other requirements.&lt;br /&gt;
&lt;br /&gt;
Characteristics of Good patterns&lt;br /&gt;
•	It solves a problem&lt;br /&gt;
•	It is a proven concept&lt;br /&gt;
•	The solution isn't obvious&lt;br /&gt;
•	It describes a relationship&lt;br /&gt;
•	The pattern has a significant human component&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP Patterns&lt;br /&gt;
&lt;br /&gt;
These belong to a type known as process patterns. They describe an appropriate way of performing tasks. GRASP stands for General Responsibility Assignment Software Patterns.&lt;br /&gt;
&lt;br /&gt;
General =&amp;gt; Abstract; widely applicable&lt;br /&gt;
Responsibility =&amp;gt; Obligations, duties&lt;br /&gt;
Assignment =&amp;gt; Giving a responsibility to a module&lt;br /&gt;
Software =&amp;gt; Computer code&lt;br /&gt;
Patterns =&amp;gt; Regularities, templates, abstractions&lt;br /&gt;
&lt;br /&gt;
There are several GRASP patterns, but we will only look at a few of the more important ones. Some of them are simply good design principles, and one can argue whether they are really patterns. For example, High Cohesion and Low Coupling are two that are well-known design principles and not really patterns.&lt;br /&gt;
&lt;br /&gt;
The full set of GRASP patterns are:&lt;br /&gt;
 Information Expert&lt;br /&gt;
 Creator&lt;br /&gt;
 Controller&lt;br /&gt;
 Low Coupling&lt;br /&gt;
 High Cohesion&lt;br /&gt;
 Polymorphism&lt;br /&gt;
 Pure Fabrication&lt;br /&gt;
 Indirection&lt;br /&gt;
 Protected Variations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GRASP can be used as a methodical approach to learning basic object design. These are patterns of assigning responsibilities. There are two types of responsibilities:&lt;br /&gt;
- Knowing responsibilities that include knowing about private encapsulated data, about related objects, and things it can derive or calculate.&lt;br /&gt;
- Doing responsibilities include doing something itself, like creating another object or doing a calculation, initiating action in other objects, and controlling and coordinating activities in other objects.&lt;br /&gt;
&lt;br /&gt;
Controller Pattern&lt;br /&gt;
&lt;br /&gt;
The Controller pattern addresses the question: Who handles a system event?&lt;br /&gt;
The events under consideration here are the ones initiated from a source outside the system. Thus the system should have some class that receives the event, but that does not necessarily mean that it should handle the event.&lt;br /&gt;
For example security video cameras are meant to receive an event wherein there is an attempt to intrude into a house but they do not take any steps to catch the intruder. Thus they are mere receivers and the event handling is done by some other part of the security system.&lt;br /&gt;
So the controller pattern can be used when we are faced with the problem of assigning responsibility of handling a system event. The solution to this problem as proposed by the controller patterns is as follows:&lt;br /&gt;
If a program receives events from external sources other than its graphical interface, add an event class to decouple the event source(s) from the objects that actually handle the events.&lt;br /&gt;
&lt;br /&gt;
The events should be handled by classes representing one of the following choices:&lt;br /&gt;
- A class that represents the overall system, device, or subsystem (facade controller).&lt;br /&gt;
- A class that represents a use case scenario within which the system event occurs. These are often named &amp;lt;usecasename&amp;gt;Handler, &amp;lt;usecasename&amp;gt;Controller, &lt;br /&gt;
&amp;lt;usecasename&amp;gt; Manager, and so forth.&lt;br /&gt;
&lt;br /&gt;
Whether to use façade controller or use case controller?&lt;br /&gt;
&lt;br /&gt;
Facade Controller&lt;br /&gt;
If we do not have a lot of messages that need to be handled by the controller, we can use a single object that represents the overall system.  For example, if we are building an application that manages our contacts, addresses, and phone numbers, you could call this object “AddressBook.”  If we are building an e-commerce website, we could call this object “Store.”  If we are building a chess game, we could call this object “ChessGame.“&lt;br /&gt;
Use Case or Session Controller&lt;br /&gt;
On the other hand, if we have a lot of messages that needed to be handled by the controller, we risk the chance of losing cohesiveness if we use a single facade controller.  In this case, we should define a single controller for all the system events associated with a single use case. So, in our e-commerce website example above, we may have several use case controllers, called “HandleReturn”, “ProcessSale”, “ProcessPayment”, “ManageAccount”, etc. Thus for most applications, the use case or session controller tends to be used.&lt;br /&gt;
Advantages of Controller Pattern&lt;br /&gt;
- There is increased potential for reuse. Using a controller object keeps external event sources and internal event handlers independent of each other’s type and behaviour.&lt;br /&gt;
- It provides more information about the states of the use case. It also enables us to ensure that the system operations occur in a legal sequence by providing more information about the current state of activity and operations within the use case.&lt;br /&gt;
Example 1&lt;br /&gt;
Consider an example of a convenience store where a cashier can trigger three events namely &lt;br /&gt;
enterItem() - Used to enter the item purchased by the customer.&lt;br /&gt;
endSale() - Marks the end of the sale and proceeds towards payment&lt;br /&gt;
makePayment() - Initiates payment by the customer.&lt;br /&gt;
The problem can be stated as: Who has the responsibility for the enterItem() event?&lt;br /&gt;
By the controller pattern we have four solutions to our problem&lt;br /&gt;
1.	It can either be the overall system indicated by POST&lt;br /&gt;
2.	It can be the overall business indicated by STORE&lt;br /&gt;
3.	It can be someone in the real world who is active in the task namely the cashier&lt;br /&gt;
4.	It can be an artificial handler of all system events of a use case denoted by BuyItemsHandler().&lt;br /&gt;
&lt;br /&gt;
                                                   POST&lt;br /&gt;
&lt;br /&gt;
                                                  STORE&lt;br /&gt;
                                             CASHIER    &lt;br /&gt;
                                                        &lt;br /&gt;
                                BuyItemsHandler&lt;br /&gt;
The choice of which one to use will be influenced by other factors such as cohesion and coupling.&lt;br /&gt;
A good design by the controller pattern is shown as follows&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is important to note how the presentation layer is decoupled from the domain layer.&lt;br /&gt;
Assigning the responsibility for system operations to objects in the domain layer rather than presentation layer supports increased reuse potential. It also makes it easier to unplug the interface layer and use a different interface technology, or to run the system in an off-line “batch” mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example 2&lt;br /&gt;
&lt;br /&gt;
A game of monopoly is a good example of a controller pattern in which the actors are the players who generate events like clicking a button with a mouse to play a game or make a move. The UI software objects (such as a JFrame window and a JButton) must process the event and cause the game to play.   When objects in the UI layer pick up an event, they must delegate the request to an object in the domain layer. &lt;br /&gt;
&lt;br /&gt;
The problem in this case can be formulated as follows:&lt;br /&gt;
What first object beyond the UI layer should receive the message from the UI layer?&lt;br /&gt;
&lt;br /&gt;
As per the controller pattern the solution is as follows:&lt;br /&gt;
Assign the responsibility to an object representing either of following:&lt;br /&gt;
- Represents the overall “system” – a root object&lt;br /&gt;
- Represents a use case scenario within which the system operation occurs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here again there is clear separation between the UI layer and the domain layer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example 3&lt;br /&gt;
&lt;br /&gt;
In an example of Jukebox program, responsibility is assigned to a controller class to handle events from external actors, e.g. startup(), playSongs(), etc. The controller class represents the overall system, device, or subsystem, which often don’t do the work, but delegate it to processing layer. Processing layer is responsible for actually doing work by calling methods such as deviceInitialize() and executePlaySongs().&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=8034</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=8034"/>
		<updated>2007-10-29T19:06:45Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in C++&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 #include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Hello&lt;br /&gt;
 {&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main( int argc, char** argv )&lt;br /&gt;
 {&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in Java&lt;br /&gt;
 public class Example1&lt;br /&gt;
 {&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in PHP&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''Examples in C#&lt;br /&gt;
 using System;&lt;br /&gt;
 &lt;br /&gt;
 public class Program&lt;br /&gt;
 {&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
&lt;br /&gt;
'''Example in Ruby&lt;br /&gt;
&lt;br /&gt;
 class Person &lt;br /&gt;
   @@count = 0 &lt;br /&gt;
   def initialize(name, height) &lt;br /&gt;
   @name = name &lt;br /&gt;
   @height = height &lt;br /&gt;
   @@count += 1 &lt;br /&gt;
  end &lt;br /&gt;
  def self.info &lt;br /&gt;
   puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
  def to_s &lt;br /&gt;
   &amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
 end'''&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
 public class Color &lt;br /&gt;
 {&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
 }&lt;br /&gt;
 public class Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase &lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived extends IBase &lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A &lt;br /&gt;
 {&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B extends A implements IDerived  &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
 public enum Color&lt;br /&gt;
 {&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
 }&lt;br /&gt;
 public struct Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase&lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived: IBase&lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A&lt;br /&gt;
 {&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B: A, IDerived &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
'''Additional Resources'''&lt;br /&gt;
&lt;br /&gt;
''Java Related resources''&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.neiu.edu/~ncaftori/java/class06.html&lt;br /&gt;
&lt;br /&gt;
http://www.javalobby.org/java/forums/t18560.html&lt;br /&gt;
&lt;br /&gt;
''Other Programming Languages''&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;br /&gt;
&lt;br /&gt;
http://rubylearning.com/satishtalim/writing_our_own_class_in_ruby.html&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=8033</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=8033"/>
		<updated>2007-10-29T19:03:07Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in C++&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 #include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Hello&lt;br /&gt;
 {&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main( int argc, char** argv )&lt;br /&gt;
 {&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in Java&lt;br /&gt;
 public class Example1&lt;br /&gt;
 {&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in PHP&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''Examples in C#&lt;br /&gt;
 using System;&lt;br /&gt;
 &lt;br /&gt;
 public class Program&lt;br /&gt;
 {&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
&lt;br /&gt;
'''Example in Ruby&lt;br /&gt;
&lt;br /&gt;
 class Person &lt;br /&gt;
   @@count = 0 &lt;br /&gt;
   def initialize(name, height) &lt;br /&gt;
   @name = name &lt;br /&gt;
   @height = height &lt;br /&gt;
   @@count += 1 &lt;br /&gt;
  end &lt;br /&gt;
  def self.info &lt;br /&gt;
   puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
  def to_s &lt;br /&gt;
   &amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
 end'''&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
 public class Color &lt;br /&gt;
 {&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
 }&lt;br /&gt;
 public class Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase &lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived extends IBase &lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A &lt;br /&gt;
 {&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B extends A implements IDerived  &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
 public enum Color&lt;br /&gt;
 {&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
 }&lt;br /&gt;
 public struct Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase&lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived: IBase&lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A&lt;br /&gt;
 {&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B: A, IDerived &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
'''Additional Resources'''&lt;br /&gt;
&lt;br /&gt;
''Java Related resources''&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.neiu.edu/~ncaftori/java/class06.html&lt;br /&gt;
&lt;br /&gt;
http://www.javalobby.org/java/forums/t18560.html&lt;br /&gt;
&lt;br /&gt;
''Other Programming Languages''&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=8029</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=8029"/>
		<updated>2007-10-29T18:56:20Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in C++&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 #include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Hello&lt;br /&gt;
 {&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main( int argc, char** argv )&lt;br /&gt;
 {&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in Java&lt;br /&gt;
 public class Example1&lt;br /&gt;
 {&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in PHP&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''Examples in C#&lt;br /&gt;
 using System;&lt;br /&gt;
 &lt;br /&gt;
 public class Program&lt;br /&gt;
 {&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
&lt;br /&gt;
'''Example in Ruby&lt;br /&gt;
&lt;br /&gt;
 class Person &lt;br /&gt;
   @@count = 0 &lt;br /&gt;
   def initialize(name, height) &lt;br /&gt;
   @name = name &lt;br /&gt;
   @height = height &lt;br /&gt;
   @@count += 1 &lt;br /&gt;
  end &lt;br /&gt;
  def self.info &lt;br /&gt;
   puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
  def to_s &lt;br /&gt;
   &amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
 end'''&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
 public class Color &lt;br /&gt;
 {&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
 }&lt;br /&gt;
 public class Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase &lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived extends IBase &lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A &lt;br /&gt;
 {&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B extends A implements IDerived  &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
 public enum Color&lt;br /&gt;
 {&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
 }&lt;br /&gt;
 public struct Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase&lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived: IBase&lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A&lt;br /&gt;
 {&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B: A, IDerived &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
'''More Resources'''&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=7050</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=7050"/>
		<updated>2007-10-24T00:46:26Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in C++&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 #include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Hello&lt;br /&gt;
 {&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main( int argc, char** argv )&lt;br /&gt;
 {&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in Java&lt;br /&gt;
 public class Example1&lt;br /&gt;
 {&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in PHP&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''Examples in C#&lt;br /&gt;
 using System;&lt;br /&gt;
 &lt;br /&gt;
 public class Program&lt;br /&gt;
 {&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
&lt;br /&gt;
'''Example in Ruby&lt;br /&gt;
&lt;br /&gt;
 class Person &lt;br /&gt;
   @@count = 0 &lt;br /&gt;
   def initialize(name, height) &lt;br /&gt;
   @name = name &lt;br /&gt;
   @height = height &lt;br /&gt;
   @@count += 1 &lt;br /&gt;
  end &lt;br /&gt;
  def self.info &lt;br /&gt;
   puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
  def to_s &lt;br /&gt;
   &amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
 end'''&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
 public class Color &lt;br /&gt;
 {&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
 }&lt;br /&gt;
 public class Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase &lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived extends IBase &lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A &lt;br /&gt;
 {&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B extends A implements IDerived  &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
 public enum Color&lt;br /&gt;
 {&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
 }&lt;br /&gt;
 public struct Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase&lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived: IBase&lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A&lt;br /&gt;
 {&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B: A, IDerived &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
Some resources to learn more about class and type are –&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6875</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6875"/>
		<updated>2007-10-23T15:21:08Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in C++&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 #include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Hello&lt;br /&gt;
 {&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 int main( int argc, char** argv )&lt;br /&gt;
 {&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in Java&lt;br /&gt;
 public class Example1&lt;br /&gt;
 {&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in PHP&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 ?&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''Examples in C#&lt;br /&gt;
 using System;&lt;br /&gt;
 &lt;br /&gt;
 public class Program&lt;br /&gt;
 {&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
&lt;br /&gt;
'''Example in Ruby&lt;br /&gt;
&lt;br /&gt;
 class Person &lt;br /&gt;
   @@count = 0 &lt;br /&gt;
   def initialize(name, height) &lt;br /&gt;
   @name = name &lt;br /&gt;
   @height = height &lt;br /&gt;
   @@count += 1 &lt;br /&gt;
  end &lt;br /&gt;
  def self.info &lt;br /&gt;
   puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
  def to_s &lt;br /&gt;
   &amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
  end &lt;br /&gt;
 end'''&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
 public class Color &lt;br /&gt;
 {&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
 }&lt;br /&gt;
 public class Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase &lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived extends IBase &lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A &lt;br /&gt;
 {&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B extends A implements IDerived  &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
 public enum Color&lt;br /&gt;
 {&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
 }&lt;br /&gt;
 public struct Point &lt;br /&gt;
 { &lt;br /&gt;
    public int x, y; &lt;br /&gt;
 }&lt;br /&gt;
 public interface IBase&lt;br /&gt;
 {&lt;br /&gt;
    void F();&lt;br /&gt;
 }&lt;br /&gt;
 public interface IDerived: IBase&lt;br /&gt;
 {&lt;br /&gt;
    void G();&lt;br /&gt;
 }&lt;br /&gt;
 public class A&lt;br /&gt;
 {&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
 public class B: A, IDerived &lt;br /&gt;
 {&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
 }'''&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
Some more resources to learn more about class and type are –&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6874</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6874"/>
		<updated>2007-10-23T15:16:52Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in C++&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Hello&lt;br /&gt;
{&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
};&lt;br /&gt;
 &lt;br /&gt;
int main( int argc, char** argv )&lt;br /&gt;
{&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
}'''&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in Java&lt;br /&gt;
public class Example1&lt;br /&gt;
{&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example of Class in PHP&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;'''&lt;br /&gt;
&lt;br /&gt;
'''Examples in C#&lt;br /&gt;
using System;&lt;br /&gt;
 &lt;br /&gt;
public class Program&lt;br /&gt;
{&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}'''&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
&lt;br /&gt;
'''Example in Ruby&lt;br /&gt;
&lt;br /&gt;
class Person &lt;br /&gt;
@@count = 0 &lt;br /&gt;
def initialize(name, height) &lt;br /&gt;
@name = name &lt;br /&gt;
@height = height &lt;br /&gt;
@@count += 1 &lt;br /&gt;
end &lt;br /&gt;
def self.info &lt;br /&gt;
puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
end &lt;br /&gt;
def to_s &lt;br /&gt;
&amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
end &lt;br /&gt;
end'''&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
public class Color &lt;br /&gt;
{&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
}&lt;br /&gt;
public class Point &lt;br /&gt;
{ &lt;br /&gt;
    public int x, y; &lt;br /&gt;
}&lt;br /&gt;
public interface IBase &lt;br /&gt;
{&lt;br /&gt;
    void F();&lt;br /&gt;
}&lt;br /&gt;
public interface IDerived extends IBase &lt;br /&gt;
{&lt;br /&gt;
    void G();&lt;br /&gt;
}&lt;br /&gt;
public class A &lt;br /&gt;
{&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class B extends A implements IDerived  &lt;br /&gt;
{&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}'''&lt;br /&gt;
&lt;br /&gt;
'''Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
public enum Color&lt;br /&gt;
{&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
}&lt;br /&gt;
public struct Point &lt;br /&gt;
{ &lt;br /&gt;
    public int x, y; &lt;br /&gt;
}&lt;br /&gt;
public interface IBase&lt;br /&gt;
{&lt;br /&gt;
    void F();&lt;br /&gt;
}&lt;br /&gt;
public interface IDerived: IBase&lt;br /&gt;
{&lt;br /&gt;
    void G();&lt;br /&gt;
}&lt;br /&gt;
public class A&lt;br /&gt;
{&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class B: A, IDerived &lt;br /&gt;
{&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}'''&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
Some more resources to learn more about class and type are –&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6873</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6873"/>
		<updated>2007-10-23T15:14:51Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
Example of Class in C++&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Hello&lt;br /&gt;
{&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
};&lt;br /&gt;
 &lt;br /&gt;
int main( int argc, char** argv )&lt;br /&gt;
{&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Example of Class in Java&lt;br /&gt;
public class Example1&lt;br /&gt;
{&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Example of Class in PHP&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Examples in C#&lt;br /&gt;
using System;&lt;br /&gt;
 &lt;br /&gt;
public class Program&lt;br /&gt;
{&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Example in Ruby&lt;br /&gt;
&lt;br /&gt;
class Person &lt;br /&gt;
@@count = 0 &lt;br /&gt;
def initialize(name, height) &lt;br /&gt;
@name = name &lt;br /&gt;
@height = height &lt;br /&gt;
@@count += 1 &lt;br /&gt;
end &lt;br /&gt;
def self.info &lt;br /&gt;
puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
end &lt;br /&gt;
def to_s &lt;br /&gt;
&amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
end &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
public class Color &lt;br /&gt;
{&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
}&lt;br /&gt;
public class Point &lt;br /&gt;
{ &lt;br /&gt;
    public int x, y; &lt;br /&gt;
}&lt;br /&gt;
public interface IBase &lt;br /&gt;
{&lt;br /&gt;
    void F();&lt;br /&gt;
}&lt;br /&gt;
public interface IDerived extends IBase &lt;br /&gt;
{&lt;br /&gt;
    void G();&lt;br /&gt;
}&lt;br /&gt;
public class A &lt;br /&gt;
{&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class B extends A implements IDerived  &lt;br /&gt;
{&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
public enum Color&lt;br /&gt;
{&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
}&lt;br /&gt;
public struct Point &lt;br /&gt;
{ &lt;br /&gt;
    public int x, y; &lt;br /&gt;
}&lt;br /&gt;
public interface IBase&lt;br /&gt;
{&lt;br /&gt;
    void F();&lt;br /&gt;
}&lt;br /&gt;
public interface IDerived: IBase&lt;br /&gt;
{&lt;br /&gt;
    void G();&lt;br /&gt;
}&lt;br /&gt;
public class A&lt;br /&gt;
{&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class B: A, IDerived &lt;br /&gt;
{&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
Some more resources to learn more about class and type are –&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6872</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 6 ubs</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_6_ubs&amp;diff=6872"/>
		<updated>2007-10-23T15:14:18Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Type vs. class. Survey the differences on type vs. class in object-oriented languages. Often, the distinction is that class pertains to an object, whereas type pertains to a variable. Consider the distinction between the two terms in several different programming languages. Cover the differences between type and class, from type-theoretic definitions to practical aspects.&lt;br /&gt;
A class is a cohesive package that consists of a particular kind of metadata. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class specifies the structure of data (a.k.a. properties, fields, attributes, data members) within each instance as well as methods (functions) (a.k.a. behaviors) which manipulate the data of the object and perform tasks. A class is the most specific type of an object in relation to a specific layer. A class may also have a representation (metaobject) at runtime, which provides runtime support for manipulating the class-related metadata. The term class is traditionally used to imply an object created by the class statement. Once a class is defined, it can be treated as a new kind of data type.&lt;br /&gt;
A type is a set of data values, and a set of operations (methods) on those values, applied to an object.  Yet another definition of type is – type is the definition of the domain of allowable values that an object may possess and the set of operations that may be performed upon the object. The terms class and type are usually (but not always) interchangeable; a type is a slightly different concept than a class, in that it emphasizes the importance of conformance to a common protocol.&lt;br /&gt;
Type defines the proper use of a name or an expression. Type can be a built-in-type or a user-defined type. In programming language like C++, type provided directly by the language such as int, double, and char* is called built-in-type. Class or Enumeration is used to define user-defined type. In Java language, types can be defined using classes and interfaces. So by creating a new class, a new type is created. But that is not true with all programming languages. For instance, in Python all classes are of type ClassType, and all class interfaces are of type InstanceType.&lt;br /&gt;
Example of Class in C++&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Hello&lt;br /&gt;
{&lt;br /&gt;
    std::string what;&lt;br /&gt;
 &lt;br /&gt;
    public:&lt;br /&gt;
        Hello(const char* s)&lt;br /&gt;
            : what(s)&lt;br /&gt;
        {&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        void say()&lt;br /&gt;
        {&lt;br /&gt;
            std::cout &amp;lt;&amp;lt; &amp;quot;Hello &amp;quot; &amp;lt;&amp;lt; what &amp;lt;&amp;lt; &amp;quot;!&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
        }&lt;br /&gt;
};&lt;br /&gt;
 &lt;br /&gt;
int main( int argc, char** argv )&lt;br /&gt;
{&lt;br /&gt;
    Hello hello_world(&amp;quot;world&amp;quot;);&lt;br /&gt;
    hello_world.say();&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
This example shows how to define a C++ class named &amp;quot;Hello&amp;quot;. It has a private string attribute named &amp;quot;what&amp;quot;, and a public method named &amp;quot;say&amp;quot;.  In this example, user-defined type is created by declaring class “Hello”.  Instance of class Hello “Hello_world” belongs to user-defined type.  Also, in line  :std::string what;”,  variable what belongs to a built-in type ‘string’.&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Example of Class in Java&lt;br /&gt;
public class Example1&lt;br /&gt;
{&lt;br /&gt;
    // This is a Java class, it automatically extends the class Object&lt;br /&gt;
    public static void main (String args[]) &lt;br /&gt;
    {&lt;br /&gt;
        System.out.println(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Example of Class in PHP&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class A {&lt;br /&gt;
    public function foo() {&lt;br /&gt;
        echo “Hello World”&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Examples in C#&lt;br /&gt;
using System;&lt;br /&gt;
 &lt;br /&gt;
public class Program&lt;br /&gt;
{&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
This example demonstrates a traditional &amp;quot;Hello world!&amp;quot; example in Microsoft's C# language. The Program class contains a single static method, Main(), which calls System.Console.WriteLine to print text onto the console.&lt;br /&gt;
////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
Example in Ruby&lt;br /&gt;
&lt;br /&gt;
class Person &lt;br /&gt;
@@count = 0 &lt;br /&gt;
def initialize(name, height) &lt;br /&gt;
@name = name &lt;br /&gt;
@height = height &lt;br /&gt;
@@count += 1 &lt;br /&gt;
end &lt;br /&gt;
def self.info &lt;br /&gt;
puts &amp;quot;Number of instances = #{@@count}&amp;quot; &lt;br /&gt;
end &lt;br /&gt;
def to_s &lt;br /&gt;
&amp;quot;Name: #{@name} Height: #{@height}&amp;quot; &lt;br /&gt;
end &lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
This defines a Person class with attributes name and height. It has a class variable count, which keeps track of the number of instances of the class created. &lt;br /&gt;
&lt;br /&gt;
Examples of Type in Java&lt;br /&gt;
&lt;br /&gt;
public class Color &lt;br /&gt;
{&lt;br /&gt;
    String Red, Blue, Green;&lt;br /&gt;
}&lt;br /&gt;
public class Point &lt;br /&gt;
{ &lt;br /&gt;
    public int x, y; &lt;br /&gt;
}&lt;br /&gt;
public interface IBase &lt;br /&gt;
{&lt;br /&gt;
    void F();&lt;br /&gt;
}&lt;br /&gt;
public interface IDerived extends IBase &lt;br /&gt;
{&lt;br /&gt;
    void G();&lt;br /&gt;
}&lt;br /&gt;
public class A &lt;br /&gt;
{&lt;br /&gt;
    protected  void H() {&lt;br /&gt;
        System.out.println(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class B extends A implements IDerived  &lt;br /&gt;
{&lt;br /&gt;
    public void F() {&lt;br /&gt;
        System.out.println(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        System.out.println(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    protected void H() {&lt;br /&gt;
        System.out.println(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Examples of Type in C#&lt;br /&gt;
&lt;br /&gt;
public enum Color&lt;br /&gt;
{&lt;br /&gt;
    Red, Blue, Green&lt;br /&gt;
}&lt;br /&gt;
public struct Point &lt;br /&gt;
{ &lt;br /&gt;
    public int x, y; &lt;br /&gt;
}&lt;br /&gt;
public interface IBase&lt;br /&gt;
{&lt;br /&gt;
    void F();&lt;br /&gt;
}&lt;br /&gt;
public interface IDerived: IBase&lt;br /&gt;
{&lt;br /&gt;
    void G();&lt;br /&gt;
}&lt;br /&gt;
public class A&lt;br /&gt;
{&lt;br /&gt;
    protected virtual void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class B: A, IDerived &lt;br /&gt;
{&lt;br /&gt;
    public void F() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.F, implementation of IDerived.F&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void G() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.G, implementation of IDerived.G&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    override protected void H() {&lt;br /&gt;
        Console.WriteLine(&amp;quot;B.H, override of A.H&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Above examples clearly demonstrate usage of type. Red, blue and green have type of ‘Color’. X, Y are ‘Point’ type.&lt;br /&gt;
&lt;br /&gt;
Here is another excerpt that distinguish class and type. &lt;br /&gt;
“Classes were created with 'class', and they were fundamentally different from C types created in extension modules. All instances of old-style classes are of type 'instance', which is why they have the __class__ attribute, so you can find their actual class. (Functions like &amp;quot;isinstance&amp;quot; contain hacks to support old-style classes.) New-style classes elevate Python-level classes to types equal to the built-in ones, which is why the word &amp;quot;type&amp;quot; is now &lt;br /&gt;
sufficient for both.”&lt;br /&gt;
&lt;br /&gt;
Some more resources to learn more about class and type are –&lt;br /&gt;
&lt;br /&gt;
http://java.sun.com/docs/books/tutorial/java/concepts/class.html&lt;br /&gt;
&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/classes.html&lt;br /&gt;
&lt;br /&gt;
http://www.ibiblio.org/g2swap/byteofpython/read/oops.html&lt;br /&gt;
&lt;br /&gt;
http://msdn2.microsoft.com/en-us/vbasic/ms789107.aspx&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5318</id>
		<title>CSC/ECE 517 Fall 2007/wiki1b 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5318"/>
		<updated>2007-10-10T01:44:09Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 '''class Dummy  &lt;br /&gt;
   def method_missing(m, *args)   &lt;br /&gt;
     puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
   end  &lt;br /&gt;
 end'''  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
  '''class SimpleCallLogger&lt;br /&gt;
    def initialize(o)&lt;br /&gt;
      @obj = o&lt;br /&gt;
    end&lt;br /&gt;
    def method_missing(methodname, *args)&lt;br /&gt;
      puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
      a = @obj.send(methodname, *args)&lt;br /&gt;
      puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
      return a&lt;br /&gt;
    end&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
   '''def method_missing(method)&lt;br /&gt;
     @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
     render_action 'index'    &lt;br /&gt;
     cache_page if ActionController::Base.perform_caching&lt;br /&gt;
   end'''&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
&lt;br /&gt;
  '''def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
    @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
    end&lt;br /&gt;
    require 'rubygems'&lt;br /&gt;
    require 'facets'&lt;br /&gt;
&lt;br /&gt;
    module James&lt;br /&gt;
    def name&lt;br /&gt;
      &amp;quot;James&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  module Lynn&lt;br /&gt;
    def name&lt;br /&gt;
      &amp;quot;Lynn&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  class FamilyMember&lt;br /&gt;
    include James&lt;br /&gt;
    include Lynn&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
&lt;br /&gt;
  '''class LolCat&lt;br /&gt;
    def confess&lt;br /&gt;
      puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def eat&lt;br /&gt;
      puts “NOM NOM NOM.”&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def method_missing(method)&lt;br /&gt;
      puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
    end&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5317</id>
		<title>CSC/ECE 517 Fall 2007/wiki1b 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5317"/>
		<updated>2007-10-10T01:43:36Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 '''class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end'''  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
  '''class SimpleCallLogger&lt;br /&gt;
    def initialize(o)&lt;br /&gt;
      @obj = o&lt;br /&gt;
    end&lt;br /&gt;
    def method_missing(methodname, *args)&lt;br /&gt;
      puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
      a = @obj.send(methodname, *args)&lt;br /&gt;
      puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
      return a&lt;br /&gt;
    end&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
   '''def method_missing(method)&lt;br /&gt;
     @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
     render_action 'index'    &lt;br /&gt;
     cache_page if ActionController::Base.perform_caching&lt;br /&gt;
   end'''&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
&lt;br /&gt;
  '''def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
    @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
    end&lt;br /&gt;
    require 'rubygems'&lt;br /&gt;
    require 'facets'&lt;br /&gt;
&lt;br /&gt;
    module James&lt;br /&gt;
    def name&lt;br /&gt;
      &amp;quot;James&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  module Lynn&lt;br /&gt;
    def name&lt;br /&gt;
      &amp;quot;Lynn&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  class FamilyMember&lt;br /&gt;
    include James&lt;br /&gt;
    include Lynn&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
&lt;br /&gt;
  '''class LolCat&lt;br /&gt;
    def confess&lt;br /&gt;
      puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def eat&lt;br /&gt;
      puts “NOM NOM NOM.”&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    def method_missing(method)&lt;br /&gt;
      puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
    end&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5316</id>
		<title>CSC/ECE 517 Fall 2007/wiki1b 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5316"/>
		<updated>2007-10-10T01:40:55Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 '''class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end'''  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
  '''class SimpleCallLogger&lt;br /&gt;
  def initialize(o)&lt;br /&gt;
    @obj = o&lt;br /&gt;
  end&lt;br /&gt;
  def method_missing(methodname, *args)&lt;br /&gt;
    puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
    a = @obj.send(methodname, *args)&lt;br /&gt;
    puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
    return a&lt;br /&gt;
  end&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
   '''def method_missing(method)&lt;br /&gt;
   @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
   render_action 'index'    &lt;br /&gt;
   cache_page if ActionController::Base.perform_caching&lt;br /&gt;
   end'''&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
&lt;br /&gt;
  '''def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
  end&lt;br /&gt;
  require 'rubygems'&lt;br /&gt;
  require 'facets'&lt;br /&gt;
&lt;br /&gt;
  module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
&lt;br /&gt;
  '''class LolCat&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
  end'''&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5315</id>
		<title>CSC/ECE 517 Fall 2007/wiki1b 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5315"/>
		<updated>2007-10-10T01:39:12Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 '''class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end'''  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
'''class SimpleCallLogger&lt;br /&gt;
  def initialize(o)&lt;br /&gt;
    @obj = o&lt;br /&gt;
  end&lt;br /&gt;
  def method_missing(methodname, *args)&lt;br /&gt;
    puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
    a = @obj.send(methodname, *args)&lt;br /&gt;
    puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
    return a&lt;br /&gt;
  end&lt;br /&gt;
end'''&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
'''def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end'''&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
&lt;br /&gt;
'''def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
&lt;br /&gt;
'''class LolCat&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5314</id>
		<title>CSC/ECE 517 Fall 2007/wiki1b 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=5314"/>
		<updated>2007-10-10T01:36:41Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 '''class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end'''  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
'''class SimpleCallLogger&lt;br /&gt;
  def initialize(o)&lt;br /&gt;
    @obj = o&lt;br /&gt;
  end&lt;br /&gt;
  def method_missing(methodname, *args)&lt;br /&gt;
    puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
    a = @obj.send(methodname, *args)&lt;br /&gt;
    puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
    return a&lt;br /&gt;
  end&lt;br /&gt;
end'''&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
'''def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end'''&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
'''def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end'''&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
'''class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end'''&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=4967</id>
		<title>CSC/ECE 517 Fall 2007/wiki1b 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1b_2_c9&amp;diff=4967"/>
		<updated>2007-10-01T13:53:43Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
class SimpleCallLogger&lt;br /&gt;
  def initialize(o)&lt;br /&gt;
    @obj = o&lt;br /&gt;
  end&lt;br /&gt;
  def method_missing(methodname, *args)&lt;br /&gt;
    puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
    a = @obj.send(methodname, *args)&lt;br /&gt;
    puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
    return a&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1_2_c9&amp;diff=4966</id>
		<title>CSC/ECE 517 Fall 2007/wiki1 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1_2_c9&amp;diff=4966"/>
		<updated>2007-10-01T13:53:17Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4965</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4965"/>
		<updated>2007-10-01T13:51:10Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1_2_c9&amp;diff=4964</id>
		<title>CSC/ECE 517 Fall 2007/wiki1 2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki1_2_c9&amp;diff=4964"/>
		<updated>2007-10-01T13:50:39Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
class SimpleCallLogger&lt;br /&gt;
  def initialize(o)&lt;br /&gt;
    @obj = o&lt;br /&gt;
  end&lt;br /&gt;
  def method_missing(methodname, *args)&lt;br /&gt;
    puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
    a = @obj.send(methodname, *args)&lt;br /&gt;
    puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
    return a&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4828</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4828"/>
		<updated>2007-09-30T16:21:18Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      '''Wiki Assignment'''&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
class SimpleCallLogger&lt;br /&gt;
  def initialize(o)&lt;br /&gt;
    @obj = o&lt;br /&gt;
  end&lt;br /&gt;
  def method_missing(methodname, *args)&lt;br /&gt;
    puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
    a = @obj.send(methodname, *args)&lt;br /&gt;
    puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
    return a&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4827</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4827"/>
		<updated>2007-09-30T16:20:11Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      Wiki Assignment&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Source: http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
 class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here, please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here, please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
In the following example, method method_missing intercepts and prints out a message with method name and argument list (if any) and forwards on the method call using 'send' method without knowing anything about the object passed to it. (source: http://blog.mauricecodik.com/2005/12/more-ruby-methodmissing.html)&lt;br /&gt;
&lt;br /&gt;
class SimpleCallLogger&lt;br /&gt;
  def initialize(o)&lt;br /&gt;
    @obj = o&lt;br /&gt;
  end&lt;br /&gt;
  def method_missing(methodname, *args)&lt;br /&gt;
    puts &amp;quot;called: #{methodname}(#{args})&amp;quot;&lt;br /&gt;
    a = @obj.send(methodname, *args)&lt;br /&gt;
    puts &amp;quot;\t-&amp;gt; returned: #{a}&amp;quot;&lt;br /&gt;
    return a&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Source: http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their web page changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Source: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (source: http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordingly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4826</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4826"/>
		<updated>2007-09-30T16:00:10Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      Wiki Assignment&lt;br /&gt;
&lt;br /&gt;
'''Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Link used http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
   class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here -please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Link http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their webpage changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Link: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (Link http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordindly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4825</id>
		<title>CSC/ECE 517 Fall 2007/wiki2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007/wiki2_c9&amp;diff=4825"/>
		<updated>2007-09-30T15:57:59Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      Wiki Assignment&lt;br /&gt;
&lt;br /&gt;
Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Link used http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
   class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here -please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Link http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their webpage changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Link: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (Link http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordindly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007wiki2_c9&amp;diff=4556</id>
		<title>CSC/ECE 517 Fall 2007wiki2 c9</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007wiki2_c9&amp;diff=4556"/>
		<updated>2007-09-25T14:54:46Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      Wiki Assignment&lt;br /&gt;
&lt;br /&gt;
Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Link used http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
   class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here -please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Link http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their webpage changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Link: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (Link http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordindly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007&amp;diff=4555</id>
		<title>CSC/ECE 517 Fall 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007&amp;diff=4555"/>
		<updated>2007-09-25T14:52:47Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007&amp;diff=4554</id>
		<title>CSC/ECE 517 Fall 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2007&amp;diff=4554"/>
		<updated>2007-09-25T14:50:51Z</updated>

		<summary type="html">&lt;p&gt;Ubsingh: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;CSC- 517 Object-Oriented Languages and Systems&lt;br /&gt;
                                      Wiki Assignment&lt;br /&gt;
&lt;br /&gt;
Topic 2 :  There are plenty of examples of method_missing on the Web. Unfortunately, I find most of them rather difficult to understand. One needs to look at quite a bit of source code and figure out what it does. Fix this by giving a plain-English description of several uses of method_missing not covered in our class, with Web links to the pages where you found them.&lt;br /&gt;
Ruby has a powerful way to intercept calls to undefined method. This is implemented by defining method_missing in our class definition. If a call is made to an undefined method on a object, Ruby passes the name of the method and its arguments to the method_missing.  This is an efficient and safest way to intercept calls made to unknown methods and handles them in a proper fashion.&lt;br /&gt;
Let us look into few examples (Link used http://rubylearning.com/satishtalim/ruby_method_missing.html&lt;br /&gt;
   class Dummy  &lt;br /&gt;
 def method_missing(m, *args)   &lt;br /&gt;
 puts &amp;quot;There's no method called #{m} here please try again.&amp;quot;  &lt;br /&gt;
 end  &lt;br /&gt;
 end  &lt;br /&gt;
Dummy.new.anything  &lt;br /&gt;
&amp;gt;ruby tmp.rb   &lt;br /&gt;
Output: There's no method called anything here -please try again.    &lt;br /&gt;
In the above example, a call is made to a method called anything on object of class Dummy. There is no method called “anything” defined within the class. Ruby passes the name “anything” to method_missing. Hence the above output is displayed. &lt;br /&gt;
&lt;br /&gt;
Another use of method_missing: (Link http://redhanded.hobix.com/inspect/theBestOfMethod_missing.html)&lt;br /&gt;
&lt;br /&gt;
 def method_missing(method)&lt;br /&gt;
    @posts = User.find_first(['username = ?', method.to_s]).posts&lt;br /&gt;
    render_action 'index'    &lt;br /&gt;
    cache_page if ActionController::Base.perform_caching&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The above code is an example of a controller used for generating RSS and Atom Feeds to user.  It is used by Elite Journal which is a multi user. Since their webpage changes display every now and then depending upon the status of user login. Therefore caching the output is very hard. Therefore, most of the time the output is not cached. So, generally the RSS and Atom Feeds are cached.  Since Elite Journal is multi-user, there is a feed for each user. This feed is combined with the method_missing call such that a call to the /rss/scott URL will retrieve the feed to the user “Scott”. In the above example, the page is cached if caching is enabled by the action controller.&lt;br /&gt;
Another set of example for the use of method_missing is as follows: (Link: facets.rubyforge.org/src/lib/facets/core/kernel/as.rb)&lt;br /&gt;
def method_missing(sym, *args, &amp;amp;blk)&lt;br /&gt;
  @ancestor.instance_method(sym).bind(@subject).call(*args,&amp;amp;blk)&lt;br /&gt;
end&lt;br /&gt;
require 'rubygems'&lt;br /&gt;
require 'facets'&lt;br /&gt;
&lt;br /&gt;
module James&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;James&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
module Lynn&lt;br /&gt;
  def name&lt;br /&gt;
    &amp;quot;Lynn&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class FamilyMember&lt;br /&gt;
  include James&lt;br /&gt;
  include Lynn&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
FamilyMember.ancestors # =&amp;gt; [FamilyMember, Lynn, James, Object, Kernel]&lt;br /&gt;
member = FamilyMember.new&lt;br /&gt;
member.name # =&amp;gt; &amp;quot;Lynn&amp;quot;&lt;br /&gt;
member.as(James).name # =&amp;gt; &amp;quot;James&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In above example method_missing definition allows you to call a method on any ancestor. Initially instance of FamilyMember i.e member receives a message as which returns an instance of As. After returning the instance of As, member receives messae “name”. Since As does not contain the definition of name, the method_missing is called where in name is passed as an arguments. Within the method, instance_method is called on the ancestor with the name as the symbol. The instance_method will return the unbound method name since it is not defined. Then, method_missing binds the name to the subject which is member (instance of FamilyMember) and sends a call message along with the arguments passed before. Here, since name binds to the member, it can access the state or behavior of the member.&lt;br /&gt;
Last example for the purpose of using method_missing. (Link http://services.tucows.com/developers/2007/08/03/rubys-method_missing-method-explained-with-lolcats/)&lt;br /&gt;
class LolCat&lt;br /&gt;
&lt;br /&gt;
  def confess&lt;br /&gt;
    puts “I made you a cookie…but then I eated it.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def eat&lt;br /&gt;
    puts “NOM NOM NOM.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  def method_missing(method)&lt;br /&gt;
    puts “Oh noes! I has no idea how to #{method}.”&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty = LolCat.new&lt;br /&gt;
=&amp;gt; #&amp;lt;LolCat:0x349a40&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.confess&lt;br /&gt;
I made you a cookie...but then I eated it.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.eat&lt;br /&gt;
NOM NOM NOM.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&amp;gt; kitty.poop&lt;br /&gt;
Oh noes! I has no idea how to poop.&lt;br /&gt;
=&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In the above example, we create an instance of LolCat which is named kitty. Next, call the method “confess” on kitty. Since it is defined , the method “confess” is called and appropriate result is printed. When the method poop is called, the method_missing is called since the method “poop” is not defined. Ruby passes the name of the method i.e “confess” and arguments that are needed to the method “poop”. The method_missing displays an error accordindly.&lt;/div&gt;</summary>
		<author><name>Ubsingh</name></author>
	</entry>
</feed>