You are on page 1of 20

Object Oriented Programming

Very basic concepts of OOP


What is OOP?
What is OOP?
• Focus to Objects instead of Actions

Structured programming
Object Oriented Programming
Class and Object
• Class is the type of Objects
• And Object is an instance of the Class

Human is a Class Mr. Hai LX is an instance of Human


Loose Coupling and
High Cohesion
High Cohesion
• A Class should do ONLY ONE THING
• If your class does more than ONE thing, BREAK it.
Loose Coupling
• A
OOP Foundations
OOP Foundations
• Abstraction
• Inheritance
• Polymorphism
• Encapsulation
Inheritance
• The evolution story
Polymorphism
Encapsulation

Why I must take care what you do?

I just need the result of the work I ask of you

Loose Coupling
Abstraction

Think of Future
We do what we
don’t really know
Solid Principles
Single responsibility principle

Do One Thing
Open/closed principle

Don’t customize

Just extend it
Liskov substitution principle

You must follow family traditions

Don’t change it
Interface segregation principle

Your Interface should be every simple

Easy to use

Don’t give your client what they don’t need


Dependency inversion principle

Don’t call me

I will call you


See you next Lesson

You might also like