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: Vinny Ramachandran

Discussion 4

From Summer 2003 Midterm Review:


Define each and give an example.

1. What is Inheritance?
2. What is Delegation?
3. What is Polymorphism?
4. What is Encapsulation?
5. What is the MVC paradigm? (For an example show an example using MVC)

My answers:
Inheritance is the process by which classes 'inherit' functionality and field values from a superclass. Basically, a subclass contains all of the functionality of its superclass. It may choose, in most cases, to either leave this functionality as is, or else override the method with its own unique code. Thus, other classes which use instantiate the subclass are able to at least access the functionality of the superclass, even if the actual code being used is specially tailored for a purpose.

Delegation is when a class moves simple, sometimes iterative or repetitive processes out into another class, which can perform some basic manipulation. This allows the originating class to remain reasonably simple, and no one class is overly complex, and therefore more difficult to maintain.

Polymorphism relies on inheritance to allow classes to treat references to a subclass as a reference to the superclass. This way, a variable of type Class A can reference to an object of Class B, if it inherits from Class A.

Encapsulation is one way to simplify code maintenance. Each class 'hides' its inner workings, making its functionality available through a set number of method calls; therefore, if that class is rewritten in the future with new functionality, there are a limited number of other changes to be made to maintain compatibility.

The MVC paradigm consists of three components: the Model, the View, and the Controller. The model is the object which is being acted upon, the View describes the way the Model is accessed, and the Controller mediates between them. This is most easily applicable to UI situations, but for a unique example: A model could be an SQL database, the controller would be the SQL interface / driver, and the View would be the object performing database operations.

Links to this Page