Object-oriented programming is an approach that provides a way of modularizing programs by forming separate memory area for data as well as functions that is used as object for making copies of modules as per requirement.
That is an object is considered to be a partition area of computer’s memory that store data and a set of operations that can access that data. The data of an object can be associated with that object. However functions of one object can access the functions of other object.
Object-oriented programming paradigm emphasizes the following aspects:
A class is an abstraction that captures the common structure and behaviour of a set of objects. It defines an object or group of objects and their behaviour. In other words, the class is a template or blueprint that defines the characteristics of an object and describes how the object should look and behave. All objects in a given class are identical in form and behaviour, but contain different data in their variables. It means that a class does not represent an object; it represents all the information and methods a typical object should have.
Objects are primary run-time entities in an object-oriented programming. They may stand for a thing that has specific application for example, a spot, a person, any data item related to program, including user-defined data types. Objects occupy space in memory. Every object has its own properties or features. An object is a specimen of a class. It can be singly recognized by its name. It declares the state shown by the data values of its characteristic at a specific time. The state of the object varies according to procedure used. It is known as the action of the object. The action of the object depends upon the member function defined within its class.
An operation required for an object or entity when coded in a class is called a method. The operations that are required for an object are to be defined in a class. All objects in a class perform certain common actions or operations. Each action needs an object that becomes a function of the class that defines it and is referred to as a method.
It is a feature of object-oriented programming by which we can hide the data members of a class, just exposing the functions of the class that can be accessed by the objects.
Abstraction directs to the procedure of representing essential features without including the background details. Classes use the theory of abstraction and are defined as a list of abstract properties such as size, cost, height, and few functions to operate on these properties. Data abstraction is the procedure of identifying properties and methods related to a specific entity as applicable to the application.
Encapsulation is the packing of data and functions into a single component. Encapsulation is the main feature of a class. The data is not accessible to a outside world and only those functions which are packed in the class can access it. These function provide the interface between the objects data and the program. This insulation of data from direct access by the program is called data hiding.
Inheritance is the method by which objects of one class get the properties of objects of another class. The class that is inherited from another class is known as subclass (also known as derived class or child class). The class from which a subclass takes the attributes and behaviour is called superclass (also known as parent class or base class).
In object-oriented programming, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without changing it. This can be achieved by deriving a new class from the existing one. The new class will have the combined features of both the classes. The real appeal and power of the inheritance mechanism is that it allows the programmer to reuse a class that is close to what he wants, and to tailor the class in such a way that it does not introduce any undesirable side-effects into the rest of the classes. Thus, inheritance is the feature that permits the reuse of an existing class to make a new class.
As you can see, Class Shape is the base class of both Rectangle and Triangle classes.
Polymorphism allows the same function to act differently in different classes. For example, an operation may exhibit different instances. The behaviour depends upon types of data used in the operation of addition. For two numbers the operation will generate a sum. If the operands are string then the operation would produce a third string by concatenation.
Binding means connecting one program to another program that is to be executed in reply to the call. Dynamic binding is also known as late binding. The code present in the specified program is unknown till it is executed. It is analogous to inheritance and polymorphism.
A message refers to a request to an object so that it can execute one of its methods. The process of requesting an object to perform one of its methods is known as message passing.
Sometimes, object-oriented programming languages consider calling of member functions as messages.
Suppose e1 is an object of employee class and displaydata() is a function of employee class. Thus, the calling of displaydata() function from e1 object using a dot(.) operator can be considered as sending a message to e1 object, telling it to display the data.
Object-oriented technology allows reusability of the classes by extending them to other classes using inheritance. Once a class is defined, the other programmer can also use it in their programs and add new features to the derived classes. Once verified the qualities of base classes need not be redefined. Thus, reusability saves time.
In object-oriented programming, two classes can be joined either by inheritance or delegation, which provide reusability of class.
In inheritance , one class can be derived from other class and relationship between them is known as kind of relationship. For example, if class y is derived from class x, then class y is known as kind of x.
The second type of relationship is has a relationship. When object of one class is used as data member in other class, such composition of objects is known as delegation.
The software components of a program have more than one version depending on the data types of arguments. This feature allows declaration of variables without specifying exact data type. The compiler identifies the data type at run-time. The programmer can create a function that can be used for any type of data. The template feature in C++ allows generic programming.
That is an object is considered to be a partition area of computer’s memory that store data and a set of operations that can access that data. The data of an object can be associated with that object. However functions of one object can access the functions of other object.
Object-oriented programming paradigm emphasizes the following aspects:
1. Class
2. Object
3. Method
4. Information hiding
5. Data abstraction
6. Encapsulation
7. Inheritance
8. Polymorphism
9. Dynamic Binding
10. Message passing
11. Reusability
12. Delegation
13. Genericity
Class
A class is an abstraction that captures the common structure and behaviour of a set of objects. It defines an object or group of objects and their behaviour. In other words, the class is a template or blueprint that defines the characteristics of an object and describes how the object should look and behave. All objects in a given class are identical in form and behaviour, but contain different data in their variables. It means that a class does not represent an object; it represents all the information and methods a typical object should have.
Object
Objects are primary run-time entities in an object-oriented programming. They may stand for a thing that has specific application for example, a spot, a person, any data item related to program, including user-defined data types. Objects occupy space in memory. Every object has its own properties or features. An object is a specimen of a class. It can be singly recognized by its name. It declares the state shown by the data values of its characteristic at a specific time. The state of the object varies according to procedure used. It is known as the action of the object. The action of the object depends upon the member function defined within its class.
Method
An operation required for an object or entity when coded in a class is called a method. The operations that are required for an object are to be defined in a class. All objects in a class perform certain common actions or operations. Each action needs an object that becomes a function of the class that defines it and is referred to as a method.
Information hiding
It is a feature of object-oriented programming by which we can hide the data members of a class, just exposing the functions of the class that can be accessed by the objects.
Data abstraction
Abstraction directs to the procedure of representing essential features without including the background details. Classes use the theory of abstraction and are defined as a list of abstract properties such as size, cost, height, and few functions to operate on these properties. Data abstraction is the procedure of identifying properties and methods related to a specific entity as applicable to the application.
Encapsulation
Encapsulation is the packing of data and functions into a single component. Encapsulation is the main feature of a class. The data is not accessible to a outside world and only those functions which are packed in the class can access it. These function provide the interface between the objects data and the program. This insulation of data from direct access by the program is called data hiding.
Inheritance
Inheritance is the method by which objects of one class get the properties of objects of another class. The class that is inherited from another class is known as subclass (also known as derived class or child class). The class from which a subclass takes the attributes and behaviour is called superclass (also known as parent class or base class).
In object-oriented programming, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without changing it. This can be achieved by deriving a new class from the existing one. The new class will have the combined features of both the classes. The real appeal and power of the inheritance mechanism is that it allows the programmer to reuse a class that is close to what he wants, and to tailor the class in such a way that it does not introduce any undesirable side-effects into the rest of the classes. Thus, inheritance is the feature that permits the reuse of an existing class to make a new class.
Inheritance |
As you can see, Class Shape is the base class of both Rectangle and Triangle classes.
Polymorphism
Polymorphism allows the same function to act differently in different classes. For example, an operation may exhibit different instances. The behaviour depends upon types of data used in the operation of addition. For two numbers the operation will generate a sum. If the operands are string then the operation would produce a third string by concatenation.
Dynamic Binding
Binding means connecting one program to another program that is to be executed in reply to the call. Dynamic binding is also known as late binding. The code present in the specified program is unknown till it is executed. It is analogous to inheritance and polymorphism.
Message passing
A message refers to a request to an object so that it can execute one of its methods. The process of requesting an object to perform one of its methods is known as message passing.
Sometimes, object-oriented programming languages consider calling of member functions as messages.
Suppose e1 is an object of employee class and displaydata() is a function of employee class. Thus, the calling of displaydata() function from e1 object using a dot(.) operator can be considered as sending a message to e1 object, telling it to display the data.
Reusability
Object-oriented technology allows reusability of the classes by extending them to other classes using inheritance. Once a class is defined, the other programmer can also use it in their programs and add new features to the derived classes. Once verified the qualities of base classes need not be redefined. Thus, reusability saves time.
Reusability |
Delegation
In object-oriented programming, two classes can be joined either by inheritance or delegation, which provide reusability of class.
In inheritance , one class can be derived from other class and relationship between them is known as kind of relationship. For example, if class y is derived from class x, then class y is known as kind of x.
Kind of relationship (Inheritance) |
The second type of relationship is has a relationship. When object of one class is used as data member in other class, such composition of objects is known as delegation.
has a relationship (Delegation) |
Genericity
The software components of a program have more than one version depending on the data types of arguments. This feature allows declaration of variables without specifying exact data type. The compiler identifies the data type at run-time. The programmer can create a function that can be used for any type of data. The template feature in C++ allows generic programming.
No comments:
Post a Comment