Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.
The programming challenge was seen as how to write the logic, not how to define the data. Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).
Object:-
An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life.
An object is an instance of class.
Real-world objects share two characteristics: They all have state and behavior. Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Bicycles also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes).
Class:-
A class is the blueprint from which individual objects are created.
class Test
{
}
The concept of Objects & Classes helps you hide your code implementation from the user of your class.
Inheritance:-
Different kinds of objects often have a certain amount in common with each other. Mountain bikes, road bikes, and tandem bikes, for example, all share the characteristics of bicycles (current speed, current pedal cadence, current gear). Yet each also defines additional features that make them different: tandem bicycles have two seats and two sets of handlebars; road bikes have drop handlebars; some mountain bikes have an additional chain ring, giving them a lower gear ratio.
Object-oriented programming allows classes to inherit commonly used state and behavior from other classes. In this example, Bicycle now becomes the superclass of MountainBike, RoadBike, and TandemBike.
it is possible to create a new class from an existing one and add new features to it. Thus inheritance provides a mechanism for class level re-usability.
class Base
{
}
class Derived : Base
{
}
Encapsulation:-
Encapsulation is process of keeping data and methods together inside objects.
public class Test
{
public Test()
{
}
protected double X;
protected double Y;
protected double Z;
public double GetABC()
{
}
}
Abstraction:-
An abstraction captures the essential features of an entity, suppressing unnecessary details. All instances of an abstraction share these common features. Abstraction helps us deal with complexity.
The implementation of an abstraction should be hidden from the rest of the system, or encapsulated. Objects have a public and a private side.
Polymorphism:-
The ability for the same method call to result in different behavior depending on the object through which the method is invoked is referred to as polymorphism.Polymorphism allows objects to be represented in multiple forms
Wednesday, October 21, 2009
Subscribe to:
Posts (Atom)