Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Liscov substitution principle

171 views

Published on

The Liskov Substitution Principle (LSP, lsp) is a concept in Object Oriented Programming that states: Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Liscov substitution principle

  1. 1. Liscov Substitution Principle
  2. 2. 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
  3. 3. The principle, that Barbara Liskov defined in 1987 in her conference keynote named "Data abstraction and hierarchy". Liscov Substitution Principle 3
  4. 4. Liskov Substitution Principle 4 Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  5. 5. 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.
  6. 6. 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. 7. 7 If class Man is inherited from class Human, then objects of class Human may be replaced with objects of class Man.
  8. 8. 8 If class ……….. is inherited from class ……………., then objects of class ……... may be replaced with objects of class ………....
  9. 9. 9 …………...without altering the correctness of that program.
  10. 10. Code Example 10
  11. 11. 11 If class AdminUser is inherited from class User, then objects of class User may be replaced with objects of class AdminUser
  12. 12. Thank You 12

×