Sunday 29 January 2012

Object Oriented Paradigm

 Introduction:
•In object oriented paradigm everything in the world is seen as objects.
•Collection or a group of objects communicating with each other is known as a community.
•Objects communicate through messages.

Object:
•Object(agent) is a self defining entity (or) an object can also be called as a real world thing.
•Object has two things:
1) State : The characteristics of an object.
2) Behavior: What the object does or what can be done to the object.

Object : Person
1) State: height, weight etc..
2) Behavior: Run(), Walk(), Sleep(), Push(), Pull()

•In programming the characteristics of an object are implemented using variables.
•Behavior of an object is implemented using a set of methods.

Messages and Methods:
•Objects communicate through messages with one another.
•A message is a request for action.
•The request is embedded within a message.
•A method is a sequence of steps to perform some action.
•When a sender object sends a message to a receiver object, the receiver accepts the message and performs an action(method) based on the message.


Responsibilities:
•In Object Oriented Programming the behavior of objects is described using responsibilities.
•It is the responsibility of the receiver to satisfy the request of the sending object.
•The collection of all the methods(responsibilities) associated with an object is known as a protocol.

Classes and Instances:
•A class is a collection of objects having similar characteristics (or) simply a class is a collection of similar objects.
•An object is an instance of a class. So, an instance is nothing but an object.
•All objects of a class have the same behavior (set of methods).
•A class specifies the behavior of an object.
•A class is also defined as a blueprint or template for all its objects.

Class Hierarchies - Inheritance:
•Classes can be arranged in a hierarchy (tree structure).
•The process of deriving the properties from a base class into a derived class or from a super class to sub class is known as inheritance.
•The class from which the properties are inherited is known as a super or base class.
•The class into which the properties are inherited is known as a sub or derived class.

Method Binding, Overriding and Exceptions:
•Method Binding: When a sender object sends a message to a receiver object, the receiver object will accept the message and associate it with a respective method in its behavior. This association of a message to a certain method is called “Method Binding”.
•Exception: Deviation from a general rule is called an exception.
•Overriding: Exceptions are solved in programming using the concept of “Overriding”. This will be introduced in Unit – 3 (Inheritance).

Summary of OOP:
•Everything is viewed as an object.
•Computations are performed by objects communicating with each other through messages.
•Each object has its own memory, which may contain other objects.
•Every object is an instance of a class, a class is simply a collection of similar objects.
•Class specifies the behavior of all the associated objects.
•Classes can be arranged in hierarchy and can be represented using hierarchical diagram or tree representation. This hierarchy is called inheritance hierarchy.



No comments:

Post a Comment