View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Discussion 4 - Jeff Watson

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 a process by which objects pass on structure and behavior to other objects. These other objects "inherit" the structure and methods of the original object. Example: ImageMorph inherits from Morph, so ImageMorph will be able to possess the structure and behavior of a Morph. ImageMorph is a Morph that has additional functionality that allows it to function more specifically as an ImageMorph.

Delegation is the activity of asking one object to perform a task for another object. Example: Creating a Pen object in the code for the Box class to perform the task of actually drawing the Box shows an example of a Box delegating a task to a Pen.

Polymorphism allows for the same message to be performed on different data. Example: Addition with integers and addition with floats are handled differently, but the same operation (+) can be performed in each case to obtain the desired results.

Encapsulation is the concept that objects have their own data and behaviors which cannot be accessed by other objects without permission. Example: Objects that contain private variables must also have public accessors and modifiers if other objects are to be able to access and modify them.

MVC is an abbreviation for Model-View-Controller. This paradigm describes "a userface in terms of a model of the real world, which is presented in a view, with user input handled by one or more controllers" (Guzdial). This paradigm is used for designing object oriented user interfaces that are maintainable. Example: In developing a Clock class to display time you could implement MVC by modeling the clock after a real world clock, presenting this model of a clock in a view, and using controllers to handle user input relevant to the Clock.

Link to this Page