What is OOP?
-
Upload
amin-uddin -
Category
Technology
-
view
147 -
download
1
description
Transcript of What is OOP?
Object Oriented Programming(OOP
)
PRESENTATION
Presented By – Amin Uddin
Overview
1. What is Object Oriented Programming?2. Object , Class
A. Attributes (Data).B. Methods (Behaviours)
3. What is class? And what’s the difference object & class?
4. Principals Of OOP A. EncapsulationB. InheritanceC. Polymorphism
OOP Thinking
What OOP?
1. Object means things or instance.2. Orientation means co-operative collections of (objects).3. Programming means sequence of instruction s that
performs action.
So Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of one or more hierarchy of classes united via inheritance relationships.
What’s wrong with starting of Object Oriented Programming?
Unfortunately most of us start Object Oriented Programming (OOP) jumping into a language book like C++, Java or C# etc.
But
First of all we should know: what’s an object and how to think in OO (Object Oriented) way.
Everything can be an object. How?
Look around you, what we see, ALL ARE OBJECTS. We see computer, chair, table, pen, air cooler, carpet etc, all these are objects. Why they are object? Pretty simple, they have some related attributes and some related activities.
Even our concept s are also objects. Like an Account.
Is it possible that any event, like war or raining, singing, thinking etc (which is not visible) can be object? The answer is YES. These can be objects also. Think, raining has attributes: is it drizzling or “cats and dogs”? Singing can be an object if we consider, in which frequency-range it is sung?
So what is not object?
Let ‘s discuss an example‘Name’ – is it an attribute or an object? Actually, it is totally depend on problem domain. See, if you are thinking about a banking solution then customer ‘Name’ will be an attribute of customer. But if it a business from where you can purchase the ‘Name’ of your new-born baby then ‘Name’ will be an object to this business. Because ‘Name’ has meaning, length, type etc.
Name Shop
Name
LengthType
Customer
NameAddressContact No
Banking Solution
Account ………….………….
What is object ?
Physical entitiesRolesInteractionsOccurrences
e.g. Submarine, Plane
e.g. Manager, CTOe.g. Buy, Contacte.g. War, Rain
Here, all are objects.
Object is the instance or real existence of class.
More about Object
Object has certain characteristics
Object can do something
Attributes
Computer
Brand nameRAM sizeProcessor type
Can addCan subtractCan multiplyCan divide
Methods
Attributes
Methods
OS name
What is class ? And what’s the difference between object & class?
Class is the blue print of object.
Computer My ComputerBrand
nameRAM sizeProcessor typeOS name
Class Object
Dell Inspiron1 GBCore 2 DueWindows VistaCan add
Can subtractCan multiplyCan divide
AddSubtractMultiplyDivide
Objects as instances of Classes
The world conceptually consists of objects
Many objects can be said to be of the same type or classMy bank account, your bank account, Bill Gates’ bank account …
We call the object type a class
What does come first? Class? or Object?
Classes reflect concepts, objects reflect instances that embody those concepts.
Daria Jane BrittanyJodie
girlclassobject
Body
Review
Anything around us can be object.
Every object has some characteristics (attributes). Every object has some responsibilities (methods). Class is the blue print of object.
Class is a generic form of any entity.
Principals Of OOP
There are three basic principals of OOP
Encapsulation
Polymorphism
Inheritance
Encapsulation
What is encapsulation?
Is the mechanism that hide complexity.
It safe resourses of an object from outside interface.
It works like a wrapper. The resources inside the wrapper.
More about Encapsulation.
Object to object interaction or communication.
Inheritance
What is Inheritance?Is the process which one object acquire the properties of another object hierarchically.
More About Inheritance
Inheritance specifies an is-a-kind-of relationship
Derived classes inherit properties and methods from a base class, allowing code reuse
Derived classes become more specialized
Base Class
Derived Classes
Animal
Elephant Cat
Classification Of InheritanceInheritance can be classified to 5 types.
Single Inheritance Hierarchical Inheritance Multi Level Inheritance Hybrid Inheritance Multiple Inheritance
1. Single Inheritance
when a single derived class is created from a single base class then the inheritance is called as single inheritance.
1. Single Inheritance
when a single derived class is created from a single base class then the inheritance is called as single inheritance.
Base Class
Derived Class
2. Hierarchical Inheritance
when more than one derived class are created from a single base class, then that inheritance is called as hierarchical inheritance.
Base
D1 D2 D3
3. Multi Level Inheritance
when a derived class is created from another derived class, then that inheritance is called as multi level inheritance.
Base
D1
D2
4. Hybrid Inheritance
Any combination of single, hierarchical and multi level inheritances is called as hybrid inheritance.
when a derived class is created from more than one base class then that inheritance is called as multiple inheritance. But multiple inheritance is not supported by .net using classes and can be done using interfaces.
Handling the complexity that causes due to multiple inheritance is very complex. Hence it was not supported in dotnet with class and it can be done with interfaces.
Class BClass A
Class C
Polymorphism
What Is Polymorphism?
AnimalObjectsAnimalObjects
Elephant
Cat
Mouse
BehaviorBehavior
Eat Grass
Eat Mouse
Eat Cheese
MethodCalled
MethodCalled
Eat ()
Eat ()
Eat ()
It is a Greak word that means many form.
Same method s works different for different data.
Relationship among different classes
Type Of Relationship Among Classes
There are three types of relationship among classes. Such as -
Association.
Aggregation
Composition
What is Association?
Association is a (*a*) relationship between two classes. It allows one object instance to cause another to perform an action on its behalf. Association is the more general term that define the relationship between two classes
Thanks
What is the difference among Association, Aggregation and Composition?
Association is a (*a*) relationship between two classes, where one class use another. But aggregation describes a special type of an association. Aggregation is the (*the*) relationship between two classes. When object of one class has an (*has*) object of another, if second is a part of first (containment relationship) then we called that there is an aggregation between two classes is Composition. Unlike association, aggregation always insists a direction. Example 1:A Company is an aggregation of People. A Company is a composition of Accounts. When a Company ceases to do business its Accounts cease to exist but its People continue to exist.
http://www.codeproject.com/Articles/330447/Understanding-Association-Aggregation-and-Composit
See M
ore
D
eta
il
??????????????????????????????????????????????????????????????????????????????????????????????????????