Tuesday 22 July 2014

Object Oriented Programming

Object Oriented Programming:
OOP is a technique in which programs are written on the basis of objects. OOP language is an easy and flexible approach for designing and organizing the program. The program is designed by using classes. It helps in developing the software, which is modular, understandable, more readable and importantly reusable.
Features of OOP:
Class:
This is a logical representation of objects.
Or it is just like a map/ model that describes the structure of related objects.
Or it is a unit which consists of properties/ attributes/ data and member functions/ methods. The data items and functions are defined within the class. A class is the significant feature that makes any language an OOP language. This is fundamental building block of object oriented program.
Object:
It is physical implementation of a class.
Or anything having physical/ real existence.
The variables or instances of a class are called objects. Object of a class consists of both the data members and member function of the class.
The member functions are used to process and access data of the object.
Each time that you create a new object, it must be based on a class. For example, you may decide to place three buttons on your form. Each button is based on the Button class and is considered one object, called an instance of the class. Each button (or instance) has its own set of properties, methods, and events.
Examples of objects are forms and controls. Forms are the windows and dialog boxes you place on the screen; controls are the components you place inside a form, such as text boxes, buttons, and list boxes.
Properties:
The characteristics of an object are called its properties.
Properties tell something about or control the behavior of an object, such as its name, color, size, or location. You can think of properties as adjectives that describe objects.
Action/ behavior/ methods/member function:
                Any activity performed by the object to achieve some task. These are verbs of OOP. Some typical methods are Close, Show, and Clear. Each of the predefined objects has a set of methods that you can use.
Encapsulation:
                The combining of data members and member functions into one unit is called encapsulation.
Information/data hiding:
                To conceal/hide the data from the outside of class.
The data of one object is hidden for the other objects of the program. This is called data hiding. The data hiding and data encapsulation are main features of OOP. The access specifier “private” is used to hide data.
Inheritance:
                The process of creating new class from already created class. Already existed class is also called super class / parent class / base class.  Newly created class is called child class / sub class / inherited class / derived class.
Advantages of inheritance:
·         reusability of the code
·         reliability of the code increases
·         easy to derive the enhance class from the existing
·         easy to represent object in the real world with the usage of inheritance
·         Effort required to derive the new class is minimized.

Reusability:
OOP provides ways of reusing the data and code. Inheritance is a technique that allows a programmer to use the code of existing class to create new class. This saves time for writing and debugging the entire code for a new class.
Abstraction:
                This is a technique used to represent real world things in class.
                Or The ability to create an abstract representation of a concept in code.
Overloading:
                The art of taking multiple functionality from the single feature.

  • Overloaded-members provide different versions of a property or method that have the same name, but that accept a different number of parameters (or parameters of different types).
  • Overridden-properties and methods are used to replace an inherited property or method. When you override a member from a base class, you replace it. Overridden members must accept the same data type and number of arguments.
  • Shadowed-members are used to create a local version of a member that has broader scope. You also can shadow a type with any other type. For example, you can declare a property that shadows an inherited method with the same name.

No comments:

Post a Comment