Академический Документы
Профессиональный Документы
Культура Документы
[Characteristic of OOP’s]
* PREPARED BY
GROUP *
* SUPERVISOR *
CERTIFICATE
DATE: - 22/09/2009
INDEX
Class :
Instantiation :
Instances of a class share the same set of attributes, yet may differ
in what those attributes contain. For example, a class "Person"
would describe the attributes common to all instances of the Person
class. Each person is generally alike, but varies in such attributes
as "height" and "weight". The class would list types of such
attributes and also define the actions which a person can perform:
"run", "jump", "sleep", "walk", etc. One of the benefits of
programming with classes is that all instances of a particular class
will follow the defined behavior of the class they instantiate.
Interfaces and methods :
Objects define their interaction with the outside world through the
methods that they expose. A method, or instance method, is a
subroutine (function) with a special property that it has access to
data stored in an object (instance). Methods that manipulate the
data of the object and perform tasks are sometimes described as
behavior.
Methods form the object's interface with the outside world; the
buttons on the front of your television set, for example, are the
interface between you and the electrical wiring on the other side of
its plastic casing. You press the "power" button to toggle the
television on and off. In this example, the television is the instance,
each method is represented by a button, and all the buttons together
comprise the interface. In its most common form, an interface is a
specification of a group of related methods without any associated
implementation of the methods.
Composition :
Languages without
inheritance
Categories of classes :
Concrete classes
Abstract classes
An abstract class, or abstract base class (ABC), is a class that
cannot be instantiated. Such a class is only meaningful if the
language supports inheritance. An abstract class is designed only as
a parent class from which child classes may be derived. Abstract
classes are often used to represent abstract concepts or entities. The
incomplete features of the abstract class are then shared by a group
of subclasses which add different variations of the missing pieces.
Sealed classes
Metaclasses
Partial classes
To the surprise of some familiar with the use of classes, classes are
not the only way to approach object-oriented programming.
Another common approach is prototype-based programming.
Languages that support non-class-based programming are usually
designed with the motive to address the problem of tight-coupling
between implementations and interfaces due to the use of classes.
For example, the Self language, a prototype-based language, was
designed to show that the role of a class can be substituted by
using an extant object which serves as a prototype to a new object,
and the resulting language is as expressive as Smalltalk with more
generality in creating objects.
Examples :
C++
Example 1
#include <iostream>
#include <string>
public:
Hello(const string& s)
: what(s)
{
}
void say()
{
cout << "Hello " << what << "!" << endl;
}
};
return 0;
}
This example shows how to define a C++ class named "Hello". It has a private
string attribute named "what", and a public method named "say".
Example 2
class MyAbstractClass
{
public:
virtual void MyVirtualMethod() = 0;
};
CONCLUSION
Referred books:
Websites visited:
1. “http://en.wikipedia.org/wiki/object-oriented
Programming”.
2. http://hdl.handle.net.
3. www.Google.com