From the course: Learning SOLID Programming Principles
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Introduction to the Liskov Substitution Principle - Python Tutorial
From the course: Learning SOLID Programming Principles
Introduction to the Liskov Substitution Principle
- [Instructor] The second solid design principle I'd like to talk about is the Liskov substitution principle. A good design satisfies the rule that it's possible to replace objects of some superclass S with objects of any subclass of S without altering any of the provable properties of that program. That is to say without breaking the program. The principle is named for Barbara Liskov who originally called the idea "strong behavioral subtyping." The idea is that the behavior of a subclass should be as correct as the behavior of the superclass. For example, if I needed to create several readers for several distinct file types, I can define them as subclasses of this abstract superclass. Note that the Liskov substitution principle doesn't specifically mention abstract classes. Since abstract classes don't do much, it's difficult to take the Liskov substitution principle literally. It's common to apply Liskov substitution to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.