C++ is one of the most versatile languages in the world. It is used nearly everywhere for everything… systems programming (operating systems, device drivers, database engines, embedded, Internet of Things, etc.)

Enter Header Image Headline Here

Monday 10 April 2017

C++ Pillars of OOP

                                 C++ Pillars of OOP


Pillars of Object Orianted Programming  :


The features which make the language ' Object Orianted Language' are called the Pillars of Objected Orianted Programming. 


Major Pillars :-


1.  Abstraction  :


1.    Getting only essential things and hiding unnecessary details is called abstraction.

2.    It is the public access region of the class.

3.    Generally, it declares the operations that can be invoked by the clients on object of 
       class.

4.    Avoid using data members in public region of class, as it may be directly change by 
       the client.


2. Encapsulation : 


 1.     Binding of data and code together is called encapsulation.

 2.     Encapsulation maintains integrity of object.

 3.     For example, the Man class has a walk () method. The code for the walk () 
         method defines exactly how a walk happens.

4.      The encapsulation is most often achived through information hiding.

5.       Information hiding is the process of hiding all the secrets of an object that do not           contribute to its essential characteristics ; typically, structure of an object is 
          hidden, as well as implementation of its methods.


3.  Modularity  :


 1.      The act of portioning a program into individual components can reduce its 
             Complexity to agree.

 2.      Modularity can be physical modularity (e.g. divide program into .h,  .cpp,  .rc   
          files) or logical modularity  (e.g.)

 3.      Modularization consists of dividing program into modules that can be compiled                 seperately, but which are  interconnected.   

 4.      Modularity helps in easier maintenance of a complex software.


 4.     Hierarchy  :


  1.       Hierarchy is ranking or ordering of abstractions.
  2.       The main purpose of hierarchy is to achive re-usability.


The hierarchies are  :

1.  Inheritance (is-a relationship) :

Acquiring all the properties (data members) and behaviors of one by another class is called inheritance.

                           

2.  Composition (has- a relationship) :

When object is made from other small object it is called composition.


A is Owner of B and B is not shareable.

3.  Aggregation (has-a relationship):


A has B, A is Owner of B, and B is shareable.


4.    Aggregation (work-for relationship):

  • Two objects works together for long time.
  •  It is a bidirectional relationship.
  • In association, both are independent entities but just working together for long duration.


5. Dependency (use -a relationship) :
  • Sometimes the relationship b/w two classes is very weak.
  • They are not implemented with member variables at all.
  • Rather they might be implemented as member function arguments.

Polymorphism  :


It is Greek word which is a combination of poly(many) + morphism (form/behavior). One interface having many behaviour such phenomenon is called polymorphism.


Types of  polymorphism :-


 1.  Compile time polymorphism :


 1.    It is also called as static polymorphism, false polymorphism, early binding.

 2.   When call to function is resolved at compile time it is called compile time 
        polymorphism.

 3.   In C++ , Compile polymorphism is achived by using function overloading and 
       operator overloading.


2. Run time polymorphism :


  1.    It is also called as dynamic polymorphism, trus polymorphism or late binding.

  2.    When call to the function resolved at run time, it is called run time polymorphism.

   3.    In C++, run time polymorphism is achieved by using function overriding.


Minor Pillars  :

1.  Concurrency :

1.   The concurrency problem arises when multiple threads  simultaneously access same 
      object.

2.   We may use a class libeary for providing threading support. 

3.   We may use interrupts to give illusion of concurrency which need hardware details.

4.   You need to take care of object synchronization when concurrency is introduced in 
      the system.


2.   Persistence  :


1.    It is  property by which object maintains its state across time and space.

2.    The concept gives rise to the concept of object oriented  database.

3.    It talks about concept of serialization and also about trannsferring object across 
       networks.


















0 comments:

Post a Comment

Popular Posts

Recent Posts

Categories

Unordered List

Text Widget