Object oriented principle
=> OBJECT
Basic building block for Object-Oriented Programming (OOP). Usually correspond to real-life entities. An object is a unit of software comprising of :
a) State / Attribute : Defines the properties of the object & the current values of each of these properties.
b) Behavior : Defines the response of an object reacts in terms of its state changes & message passing.
c) Identity : Defines an unique name.
EXAMPLE:
Car, Mobile phone, An invoice, John
Object : John
a) State / Attribute : Defines the properties of the object & the current values of each of these properties.
b) Behavior : Defines the response of an object reacts in terms of its state changes & message passing.
c) Identity : Defines an unique name.
EXAMPLE:
Car, Mobile phone, An invoice, John
Object : John
=> CLASS
=> User-defined data type.
=> Used to represent a template for several similar type of objects.
=> Describes how the objects are structured internally.
=> Objects of the same class have the same definition both for their state & behavior.
Example:
CLASS : PERSON
=> Used to represent a template for several similar type of objects.
=> Describes how the objects are structured internally.
=> Objects of the same class have the same definition both for their state & behavior.
Example:
CLASS : PERSON
=> INSTANCE
=> Creation of an object for a particular class.
=> Attributes & behavior are described by the class.
=> Each instance has a unique identity.
=> Several different instances can be created from the same class.
=> Each instance will have different internal states depending upon the different sequences of operations performed.
CLASS : PERSON
Instance of
=> Attributes & behavior are described by the class.
=> Each instance has a unique identity.
=> Several different instances can be created from the same class.
=> Each instance will have different internal states depending upon the different sequences of operations performed.
CLASS : PERSON
Instance of
=> INHERITANCE
A property which allows a class to inherit the properties from another class. Supports the concept of hierarchical classification. The parent class is known as base class and the descendent class is known as derived class. The base class serves as a pattern for the derived class.
Advantages
Core idea for reuse in the software industry. Useful for easy modification of models. Useful for avoiding redundancy , leading to smaller models that are easier to understand.
Types of Inheritance
a) Single Inheritance : If the derived class inherits from a single parent, the inheritance is said to be single inheritance.
b) Multiple Inheritance : If the derived class inherits from two or more parents, the inheritance is said to be multiple inheritance.
Advantages
Core idea for reuse in the software industry. Useful for easy modification of models. Useful for avoiding redundancy , leading to smaller models that are easier to understand.
Types of Inheritance
a) Single Inheritance : If the derived class inherits from a single parent, the inheritance is said to be single inheritance.
b) Multiple Inheritance : If the derived class inherits from two or more parents, the inheritance is said to be multiple inheritance.
=> POLYMORPHISM
=> Ability to take more than one form
=> The same operation may exhibit different behavior in different instances.
=> Behavior depends upon the types of data used in the operation.
EXAMPLE
Operation to be performed : Addition
Input Data Type Result
Integer Sum
Character Concatenated String
Advantages
=> Extensively used in implementing inheritance.
=> Allows objects having different internal structures to share the same external interface.
=> The same operation may exhibit different behavior in different instances.
=> Behavior depends upon the types of data used in the operation.
EXAMPLE
Operation to be performed : Addition
Input Data Type Result
Integer Sum
Character Concatenated String
Advantages
=> Extensively used in implementing inheritance.
=> Allows objects having different internal structures to share the same external interface.
TYPES OF POLYMORPHISM
(a) Compile-time Polymorphism
Achieved with static binding. The procedure call is replaced with memory address statically at compile-time. Polymorphism is achieved with function overloading. Function Overloading means that in a program more than one functions can be defined with the same name & return type. The type & number of parameters can vary.
(b) Run-time Polymorphism
Achieved with dynamic binding. At run-time the procedure call matching the object under current reference will be called. This gives objects the ability to respond to messages from routines when the object’s exact type is not known till the run-time.
Helps in data hiding.
Achieved with static binding. The procedure call is replaced with memory address statically at compile-time. Polymorphism is achieved with function overloading. Function Overloading means that in a program more than one functions can be defined with the same name & return type. The type & number of parameters can vary.
(b) Run-time Polymorphism
Achieved with dynamic binding. At run-time the procedure call matching the object under current reference will be called. This gives objects the ability to respond to messages from routines when the object’s exact type is not known till the run-time.
=> DATA ABSTRACTION
Refers to the act of representing essential features without including the background details or explanations. Controls the visibility of information. Focuses upon the essential characteristics of some object, relative to the perspective of the viewer.=> ENCAPSULATION
The method of combining the data member & member functions of an object into a single structure / unit (called class). Isolates the functional details of the object from outside the class.Helps in data hiding.



No comments:
Post a Comment