Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Discussion 4 - Kevin Legette
Define each and give an example.
What is Inheritance?
What is Delegation?
What is Polymorphism?
What is Encapsulation?
What is the MVC paradigm? (For an example show an example using MVC)
Inheritance is the ability of an object/class to take on the structure and behaviors of another class (superclass) and therefore use methods defined in the superclass, while still having it's own independent structures and behaviors that seperate it from the superclass.
Example: In an application simulating a football game, a Linebacker class could inherit certain behaviors and structures from a Player class, but the Linebacker class would define its own behaviors that would distinguish it from a Quarterback.
Delegation is the ability of a class/object to request that another class/object perform a particular operation and return the result(s) of that operation to the requesting class/object.
Example: The user interface for a clock display application, would perhaps ask another object (say Clock) for the time, and use the results from this request to display the time to the user.
Polymorphism is the ability of one message to perform different operations that vary based on the type of data that the message is called on. So, where the basic functionality of the message may be similar in our minds, the actual actions performed by the machine is different, depending on the data being operated on.
Example: In many programming languages, the '+' operator will add two numbers together, but when called on a pair of strings, will concatenate the two strings together. Two very different operations, but same message.
Encapsulation can be defined as a way of protecting the "insides" or data and behaviors of a particular object from unwanted access manipulation. With encapsulation, data can't be accessed or changed without a message to the object requesting for the action to take place, then the action is handled by the object itself rather than an outside source.
Example: The most common example of encaupsulation is the use of getters/setters to access data stored in an object. Most object attributes are private to that object so can't be referenced directly, but can be accessed or changed by using the public get/set methods of that object.
The MVC paradigm splits the building of user interfaces in Smalltalk into pieces that make development easy and flexible.
The Model is simply the object from the problem domain.
The View is responsible for accepting user input and displaying the output and results to the user.
The Controller basically handles all the input events (such as keystrokes and mouse presses) and passes them to the view for appropriate processing.
Example: To simulate a calculator, the Model would be the calculator, the view would be the display of the results field and buttons on the calculator, and the controller would recognize when buttons are pressed, and send that information to the view to be processed and display the results.
Links to this Page
- Kevin Legette last edited on 9 October 2005 at 10:21 pm by adsl-83-202-242.asm.bellsouth.net
- Fall 2005 Discussion 4 last edited on 6 December 2005 at 3:45 pm by r36h51.res.gatech.edu