Thursday, July 13, 2017

Object Oriented Approach Programming

  What is object-oriented Programming ??

    The object-oriented approach views a system as a collection of real-world objects. The real world consists of objects that are categorized as classes.

      Object-oriented systems are based on classes. A class categorized a set of objects that share common attributes and behaviors. The attributes represents the properties of the class. The behaviors represents the operations that can be performed by the class. For Example, consider a class called vehicle. This class has attributes such as make of the vehicle, color, engine power, start, move, accelerate and stop. Therefore, we can say that an object is an instance of a class that demonstrates the attributes and behaviors of the class. The BMW Motorcycle owned by Mark is an object that has been instantiated from the class vehicle. 

        Features Of Object Orientation

(1) Abstraction : While buying a washing machine we concentrate on the features that a particular brand of washing machine offers, such as the wash mode, color in context of our machine requirements. However, if an engineer comes to repair your washing machine, he would concentrate on the inside of the machine. The working of the different components of the machine and the item code of the part to be replaced. 
       Here, you as a user of the washing machine, concentrate on the essential attributes and behaviors from your point of view, where as the engineer looks at the washing machine at a different level of details. 

      Abstraction, therefore represents the essential characteristics of an object or a class that differentiates it from other objects or classes with represent to the viewers perspective. 

(2) Inheritance : Inheritance is a mechanism,which helps you to generalize common attributes and behaviors in separate classes from which various sub-classes can derived.
        Example : The automatic washing machine class is subclass of the washing machine class it should contain only those attributes and behaviors that are specific to it. Other attributes and behaviors are inherited from the washing machine.

(3) Encapsulation : Encapsulation helps you to hide unnecessary behaviors or attributes from the user and show only those attributes or behaviors that the users can directly use. 
    Example : The users of the washing machine need not know the intricacies of the internal working of the washing machine. They only need to know certain functions such as switch as on/off wash mode settings and so on.

(4) Polymorphism : Polymorphism is the ability of an object-oriented to be behave differently under different circumstances. 

     Example : Marks's washing machine is an object oriented of the washing machine class. It behaves differently based on the mode settings. If the mode setting is "Wash" the machine performs the washing operation, where as if the mode is "Spin Dry" a different action is performed.


Main advantages of Object-Oriented Approach :
     - The major reasons for preferring the object oriented approach are : 
  1. Realistic Modeling 
  2. Re-usability
  3. Resilience to change
For more programming knowledge please keep visit my blog.    
          

0 comments:

Post a Comment