Liscov Substitution
Principle
S: Single Responsibility Principle
O: Open/Closed for Principle
L: Liskov Substitution Principle
I: Interface Segregation Principle
D: Dependency Inversion Principle
SOLID
Principles
2
OOD principles
Not design Patterns
By Bob Martin and
Michel Features
The principle, that Barbara
Liskov defined in 1987 in her
conference keynote named
"Data abstraction and
hierarchy".
Liscov Substitution
Principle
3
Liskov Substitution
Principle
4
Objects in a program
should be replaceable
with instances of their
subtypes without
altering the correctness
of that program.
Liskov Substitution
Principle
5
You should be able to
replace any instances of a
parent class with an
instance of one of its
children without creating
any unexpected or incorrect
behaviors.
Objects in a program should be replaceable with
instances of their subtypes without altering the
correctness of that program.
You should be able to replace any instances of a
parent class with an instance of one of its children
without creating any unexpected or incorrect
behaviors.
Liskov Substitution
Principle
6
If S is a subtype
of T, then objects
of type T may be
replaced with
objects of type S
7
If class Man is inherited
from class Human, then
objects of class Human
may be replaced with
objects of class Man.
8
If class ……….. is inherited
from class ……………., then
objects of class ……... may
be replaced with objects of
class ………....
9
…………...without altering the
correctness of that program.
Code Example
10
11
If class AdminUser is
inherited from class User,
then objects of class User
may be replaced with
objects of class AdminUser
Thank You
12

Liscov substitution principle

  • 1.
  • 2.
    S: Single ResponsibilityPrinciple O: Open/Closed for Principle L: Liskov Substitution Principle I: Interface Segregation Principle D: Dependency Inversion Principle SOLID Principles 2 OOD principles Not design Patterns By Bob Martin and Michel Features
  • 3.
    The principle, thatBarbara Liskov defined in 1987 in her conference keynote named "Data abstraction and hierarchy". Liscov Substitution Principle 3
  • 4.
    Liskov Substitution Principle 4 Objects ina program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • 5.
    Liskov Substitution Principle 5 You shouldbe able to replace any instances of a parent class with an instance of one of its children without creating any unexpected or incorrect behaviors.
  • 6.
    Objects in aprogram should be replaceable with instances of their subtypes without altering the correctness of that program. You should be able to replace any instances of a parent class with an instance of one of its children without creating any unexpected or incorrect behaviors. Liskov Substitution Principle 6 If S is a subtype of T, then objects of type T may be replaced with objects of type S
  • 7.
    7 If class Manis inherited from class Human, then objects of class Human may be replaced with objects of class Man.
  • 8.
    8 If class ………..is inherited from class ……………., then objects of class ……... may be replaced with objects of class ………....
  • 9.
  • 10.
  • 11.
    11 If class AdminUseris inherited from class User, then objects of class User may be replaced with objects of class AdminUser
  • 12.