Saturday, September 13, 2008

Object Oriented Programming

Constructors
Constructors allow you to create an object and provide it with an initial set of data so it can initialize properly. Without constructors, you create an object, then need to all a separate method to initialize it. Two steps.

Encapsulation
Is data hiding. You can create a set of procedures or methods and properties that form an interface. Other code can then use these methods with any knowledge of the code within the methods. The procedures or methods you write is called an implementation. The implementation is encapsulated within the interface.

Inheritance
The concept that an object can gain the interface and actual behaviors (implementation) of another object, then extend that interface or those behaviors. Say you create a generic Product object that handles things common to all your products. From it you may create specialized Perishable and Non-Perishable objects. Both objects inherit the original Product object's interface and behaviors but can extend or change some of those behaviors.

Initializers
An initializer allows you to declare a variable and assign it an initial value all in one statement.

Object-Based
This loosely describes a language that interacts with objects easily and directly.

Object-Oriented
Object oriented languages must support polymorphism, inheritance and encapsulation (PIE).

Overloading
This allows you to declare multiple procedures with the same name in the same scope each having different input parameter specifications. For instance, you many define a function CreateTotal that totals the values in its array argument and another CreateTotal function that takes 5 long arguments and returns their sum. You call CreateTotal and pass it the proper parameters and the language will know which version of the function to use.

Overriding
When using inheritance your new class gets all the methods from its parent or super class. However you may want a different implementation for one of these methods. You do so by overriding the original (inherited) method with your own code. Your new code may even call the original method in the parent class.

Polymorphism
This is the ability to have two different objects of two different types both implement the same method. It lets you write code that calls that method regardless of which type of object is in use at the moment.

Shared Members
Otherwise know as class, static or instance members. Shared members are methods or variables that are equally available to all instances of a class. Every object that you create, based on a given class, shares these same variables and routines.

User Interface Inheritance
Means you can create a VB form template then derive all your other forms from this template. All other forms will inherit the look and code from the template form. A change to the original form will propagate out to all the child forms.


More information:

http://en.wikipedia.org/wiki/Object-oriented_programming

No comments: