Object Oriented Programming: By: Irfan U. Memon
Object Oriented Programming: By: Irfan U. Memon
Programming
BY: IRFAN U. MEMON
B.E (SOFTWARE ENGINEERING)
MEHRAN UET. JAMSHORO
Prerequisites
Foundations of Programming
Programming Fundamentals
Outlines
Programming Paradigms
Object Oriented Programming
(OOP)?
Need of OOP
Classes
Objects
Programming Paradigms
Structural Programming
Object Oriented Programming.
Data
Logic
Data
Logic
Data
Logic
What is An Object?
What are object in real world?
Things
Is this desk?
This Computer?
A Pen?
Objects in Computer
Objects are instances of Class.
Things that have Identity, Attribute &
behavior.
An object is basically a block of
memory that has been allocated and
configured according to the blueprint
Objects in Computer
An object is anything that can be
modelled as data (properties) and
operations on that data (methods).
Gender: Male
walk()
talk()
Gender: Female
walk()
talk()
Person Object
Person Object
What is a Class?
Class
Classes are templates or
blueprints which are followed to
create an Object.
A detailed description or
definition.
A is not an object it self.
Behavior
Walk
Run
Jump
Speak
sleep
Methods
Walk
Run
Jump
Speak
sleep
Object Oriented
Paradigm
Abstraction
Polymorphism
Inheritance
Encapsulation
Abstraction
Encapsulation
Idea of surrounding something
Bundling the attributes and
behavior in the same class.
Also want restrict access in or
out of the class. (Data Hiding)
Black Boxing.
Why Hiding?
Inheritance
Creating a class based on
another class
Code Re-use
Base Class is know as Super
class
New formed class as Child
Class
Polymorphism
Poly Many, morph shapes
It enables us automatically do
the correct behavior even if
what we are working with can
many forms.
take
(+) sign
Methods
Defining Methods in C#
The syntax for defining a method in C# is as follows
<Access Specifier> <Return Type> <Method Name>
(Parameter List)
{
Method Body
}
Types of Methods
Procedure
A method is known as procedure if it does not return
any value
OR
If its return type is void
Function
A method is known as function if it do returns any
value
OR
If its return type is not void