OOPS
Its a programming methodology to organize complex system into small system with the help of class and object.
4 major elements /parts/pillars
There are 4 major pillars and 3 minor pillars of oops concept.
Major Pillars
1>Abstraction
2>Encapsulation
3>Modularity
4>Hierachy
By major , we mean that model without any one of these elements is not object oriented.
Minor Pillars
1 Typing /Polymorphism
2 Concurrency
3 Persistence
By minor we means that each of these elements is useful but not essential part of the object model
If language support all major pillars of oops then it is called object oriented programming Language.
Ex: Simula, Small Talk, C++, Java, Vb.net , Ruby
More than 2000 language in the world are object oriented.
If language support all four major pillar and all three minor pillars of oops then it is called pure object oriented language .
Ex: Small Talk, Java, C++
If language support atleast polymorphism and inheritance then it is considered as object oriented programming language .
Language which support some of the features of object oriented programming language but not all such language are called object based programming language .
ex: Visual Basic , Modula2, Ada.
Ada is first object based programming language .
Simula is first object oriented programming language.
Abstraction
It is a process of getting essential things of the object.
Abstraction focus on essential characteristics of some object releative to the perspective of the viewer.
Giving call to the member function by using object of a class indicates abstraction programatically.
Encapsulation
Implementation of abstraction is called encapsulation.
Binding of data and code together is called encapsulation.
Class is the basic unit of encapsulation
Encapsulation represents internal representation of the object.
Abstraction and encapsulation is totally independent of each other .
Data Hiding / Information hiding
Its a process of declaring data member as a private or protected.
To achieve data hiding it is necessary to use encapsulation.
To achieve data security it is necessary to use data hiding .
Data Security :
Its a process of giving controlled access to the member of the class.
Modularity :
Its a process of dividing complex system into small small modules (Class)
Advantage of abstraction :We try to minimise the complexity.
If we want to minimise module dependency we should use modularity.
There are two types of modularity
1> Logical Modularity
2>Physical Modularity
In C++ we can achieve logical modularity with namespace .
We can achieve physical modularity by dividing code into multiple files.
Typing /Polymorphism:
Typing is also called polymorphism.
Polymorphism is a greek word is a combination of two words (Poly and Morphism) (Many forms).
One interface having many behaviour this concept is called polymorphism.
Without changing interface if we want to add new functionality in existing system we should use polymorphism.
There are two types of polymorphism.
1>Compile time polymorphism
2>Run Time Polymophism
Compile Time polymophism/static polymophism/static binding/early binding/weak polymorphism/false polymorphism :
If binding between object and function get reserved at compile time then it is called compile time polymorphism.
If call to the function gets reserved at compile time then it is called compile time polymorphism.
In C++ we can achieve compile time polymorphism by using two ways.
1 Function Overloading
2 Operator overloading.
Run Time Polymophism/dynamic polymophism/dynamic binding/Late binding /Strong polymorphism/True Polymorphism
If binding between object and function gets reserved at runtime then it is called run time polymorphism.
If call to the function gets reserved at run time then it is called run time polymorphism.
Concurrency :
Its a process of executing multiple task simultaneously.
In object oriented programming language we can achieve multitasking with the help of multithreading.
Persistence :
Process of storing state of the object either inside file or database .
In C++ we can achieve persistence with the help of file handling.
Hierachy :
It is a major pillar of oops concept which is used to achieve code re-usability
Level or order or Ranking of abstraction is called Hierachy.
Types of hierachy :
There are 4 types of Hierachy.
1> has-a
2>is-a
3>use-a (dependency)
4>creates-a (instantiation)
we can achieve has a hierachy with the help of composition.
has a releationship is called part of releationship
Ex: Mobile has a sim card. Maruti has Engine. House has bathroom.
we can achieve is a hierachy with the help of Inheritance.
Ex:House is a building . Car is a vehicle.
When object is a component or part of another object it is called composition.
For Ex : System unit has a motherboard, Mobile phone has a simcard ,Room has a wall.
If we declare object of a class as a data member into another class then it is composition programatically.
Inheritance :
It is a journey from Generalization to Specialization .
In C++ Parent class is called Base class and child class is called Derived Class.
class TPerson //Base Class /Parent Class
{
};
class TEmployee::public TPerson //Child Class/Derived Class
{
};
At the time of inheritance data member & member function of base class gets inherited into the derived class.
Following functions donot inherit into the derived class
1> Constructor
2> Destructor
3>Copy Constructor
4>Assignment operator function
5> Friend function
Size of derived class object = size of all non static data member declared in base class + size of all the non static data member declared in the derived class .
Static as well as non static members of base class gets inherited into derived class.
It is a process of acquiring properties and behaviour of base class by the derived class.
To access member of base class inside member function of derived class we should use class name and scope resolution operator.
If name of base class and derived class member function is same preference is always given to the derived class member function.
If we create object of derived class first base class constructor gets called and then derived class constructor gets called .
Destructor calling sequence is exactly opposite .
If you want to initialize data member of base class from derived class we should use constructor base initializer list.
In C++ we can call base class constructor from derived class constructor with the help of constructor base initializer list.
We can use constructor base initializer list and member initializer list together .
Constructor member initializer list is used to initialize data member of the same class .
Constructor base initializer list is used to initialize data members of the base class.
Constructor base initializer list indicates explicit call to constructor .
E
Its a programming methodology to organize complex system into small system with the help of class and object.
4 major elements /parts/pillars
There are 4 major pillars and 3 minor pillars of oops concept.
Major Pillars
1>Abstraction
2>Encapsulation
3>Modularity
4>Hierachy
By major , we mean that model without any one of these elements is not object oriented.
Minor Pillars
1 Typing /Polymorphism
2 Concurrency
3 Persistence
By minor we means that each of these elements is useful but not essential part of the object model
If language support all major pillars of oops then it is called object oriented programming Language.
Ex: Simula, Small Talk, C++, Java, Vb.net , Ruby
More than 2000 language in the world are object oriented.
If language support all four major pillar and all three minor pillars of oops then it is called pure object oriented language .
Ex: Small Talk, Java, C++
If language support atleast polymorphism and inheritance then it is considered as object oriented programming language .
Language which support some of the features of object oriented programming language but not all such language are called object based programming language .
ex: Visual Basic , Modula2, Ada.
Ada is first object based programming language .
Simula is first object oriented programming language.
Abstraction
It is a process of getting essential things of the object.
Abstraction focus on essential characteristics of some object releative to the perspective of the viewer.
Giving call to the member function by using object of a class indicates abstraction programatically.
Encapsulation
Implementation of abstraction is called encapsulation.
Binding of data and code together is called encapsulation.
Class is the basic unit of encapsulation
Encapsulation represents internal representation of the object.
Abstraction and encapsulation is totally independent of each other .
Data Hiding / Information hiding
Its a process of declaring data member as a private or protected.
To achieve data hiding it is necessary to use encapsulation.
To achieve data security it is necessary to use data hiding .
Data Security :
Its a process of giving controlled access to the member of the class.
Modularity :
Its a process of dividing complex system into small small modules (Class)
Advantage of abstraction :We try to minimise the complexity.
If we want to minimise module dependency we should use modularity.
There are two types of modularity
1> Logical Modularity
2>Physical Modularity
In C++ we can achieve logical modularity with namespace .
We can achieve physical modularity by dividing code into multiple files.
Typing /Polymorphism:
Typing is also called polymorphism.
Polymorphism is a greek word is a combination of two words (Poly and Morphism) (Many forms).
One interface having many behaviour this concept is called polymorphism.
Without changing interface if we want to add new functionality in existing system we should use polymorphism.
There are two types of polymorphism.
1>Compile time polymorphism
2>Run Time Polymophism
Compile Time polymophism/static polymophism/static binding/early binding/weak polymorphism/false polymorphism :
If binding between object and function get reserved at compile time then it is called compile time polymorphism.
If call to the function gets reserved at compile time then it is called compile time polymorphism.
In C++ we can achieve compile time polymorphism by using two ways.
1 Function Overloading
2 Operator overloading.
Run Time Polymophism/dynamic polymophism/dynamic binding/Late binding /Strong polymorphism/True Polymorphism
If binding between object and function gets reserved at runtime then it is called run time polymorphism.
If call to the function gets reserved at run time then it is called run time polymorphism.
Concurrency :
Its a process of executing multiple task simultaneously.
In object oriented programming language we can achieve multitasking with the help of multithreading.
Persistence :
Process of storing state of the object either inside file or database .
In C++ we can achieve persistence with the help of file handling.
Hierachy :
It is a major pillar of oops concept which is used to achieve code re-usability
Level or order or Ranking of abstraction is called Hierachy.
Types of hierachy :
There are 4 types of Hierachy.
1> has-a
2>is-a
3>use-a (dependency)
4>creates-a (instantiation)
we can achieve has a hierachy with the help of composition.
has a releationship is called part of releationship
Ex: Mobile has a sim card. Maruti has Engine. House has bathroom.
we can achieve is a hierachy with the help of Inheritance.
Ex:House is a building . Car is a vehicle.
When object is a component or part of another object it is called composition.
For Ex : System unit has a motherboard, Mobile phone has a simcard ,Room has a wall.
If we declare object of a class as a data member into another class then it is composition programatically.
Inheritance :
It is a journey from Generalization to Specialization .
In C++ Parent class is called Base class and child class is called Derived Class.
class TPerson //Base Class /Parent Class
{
};
class TEmployee::public TPerson //Child Class/Derived Class
{
};
At the time of inheritance data member & member function of base class gets inherited into the derived class.
Following functions donot inherit into the derived class
1> Constructor
2> Destructor
3>Copy Constructor
4>Assignment operator function
5> Friend function
Size of derived class object = size of all non static data member declared in base class + size of all the non static data member declared in the derived class .
Static as well as non static members of base class gets inherited into derived class.
It is a process of acquiring properties and behaviour of base class by the derived class.
To access member of base class inside member function of derived class we should use class name and scope resolution operator.
If name of base class and derived class member function is same preference is always given to the derived class member function.
If we create object of derived class first base class constructor gets called and then derived class constructor gets called .
Destructor calling sequence is exactly opposite .
If you want to initialize data member of base class from derived class we should use constructor base initializer list.
In C++ we can call base class constructor from derived class constructor with the help of constructor base initializer list.
We can use constructor base initializer list and member initializer list together .
Constructor member initializer list is used to initialize data member of the same class .
Constructor base initializer list is used to initialize data members of the base class.
Constructor base initializer list indicates explicit call to constructor .
E
No comments:
Post a Comment