34
Object Oriented Programming(OOP) PRESENTATION Presented By – Amin Uddin

What is OOP?

Embed Size (px)

DESCRIPTION

It is for beginner's.

Citation preview

Page 1: What is OOP?

Object Oriented Programming(OOP

)

PRESENTATION

Presented By – Amin Uddin

Page 2: What is OOP?

Overview

Page 3: What is OOP?

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

Page 4: What is OOP?

OOP Thinking

Page 5: What is OOP?

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.

Page 6: What is OOP?

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.

Page 7: What is OOP?

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?

Page 8: What is OOP?

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 ………….………….

Page 9: What is OOP?

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.

Page 10: What is OOP?

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

Page 11: What is OOP?

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

Page 12: What is OOP?

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

Page 13: What is OOP?

What does come first? Class? or Object?

Classes reflect concepts, objects reflect instances that embody those concepts.

Daria Jane BrittanyJodie

girlclassobject

Page 14: What is OOP?

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.

Page 15: What is OOP?

Principals Of OOP

Page 16: What is OOP?

There are three basic principals of OOP

Encapsulation

Polymorphism

Inheritance

Page 17: What is OOP?

Encapsulation

Page 18: What is OOP?

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.

Page 19: What is OOP?

More about Encapsulation.

Object to object interaction or communication.

Page 20: What is OOP?

Inheritance

Page 21: What is OOP?

What is Inheritance?Is the process which one object acquire the properties of another object hierarchically.

Page 22: What is OOP?

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

Page 23: What is OOP?

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.

Page 24: What is OOP?

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

Page 25: What is OOP?

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.

Page 26: What is OOP?

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

Page 27: What is OOP?

Polymorphism

Page 28: What is OOP?

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.

Page 29: What is OOP?

Relationship among different classes

Page 30: What is OOP?

Type Of Relationship Among Classes

There are three types of relationship among classes. Such as -

Association.

Aggregation

Composition

Page 31: What is OOP?

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

Page 32: What is OOP?

Thanks

Page 33: What is OOP?

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

Page 34: What is OOP?

??????????????????????????????????????????????????????????????????????????????????????????????????????