Liskov Substitution Principle Tutorial with Java Coding Example for Begi...
Liskov Substitution Principle Tutorial with Java Coding Example for Beginners
Liskov Substitution principle is the third principle of SOLID principles. Liskov Substitution principle states that objects of a superclass should be replaceable with objects of its subclasses without breaking the application. The Liskov Substitution principle was introduced by Barbara Liskov in her conference keynote “Data abstraction” in 1987. It extends the Open/Closed principle and enables you to replace objects of a parent class with objects of a subclass without breaking the application.
This requires all subclasses to behave in the same way as the parent class. To achieve that, your subclasses need to follow these rules:
1. Don’t implement any stricter validation rules on input parameters than implemented by the parent class.
2. Apply at the least the same rules to all output parameters as applied by the parent class.
In simple words, what we want is to have the objects of our subclasses behaving the same way as the objects of our superclass. So, the next time by mistake if you create an object of the subclass instead of super class, you should still be fine considering LSP. An overridden method of a subclass needs to accept the same input parameter values as the method of the superclass. Similar rules apply to the return value of the method. The return value of a method of the subclass needs to comply with the same rules as the return value of the method of the superclass.
Remember If you decide to apply Liskov Substitution principle to your code, that means the behavior of your classes is more important for you than its structure.
** Use of Liskov Substitution Principle **
1. Use Liskov Substitution want to replace parent object with the child class object.
2. Use Liskov Substitution if you want to reuse code.
3. Use Liskov Substitution if you want reduce software maintenance effort.
4. Use Liskov Substitution principle when you want loose coupling between software components.
** Benefits of Open-Closed Principle **
1. Liskov Substitution principle gives us a loosely-coupled, flexible set of classes to handle changing requirements.
2. Liskov Substitution principle helps in Code Reusability.
3. Liskov Substitution principle makes software maintainable.
4. Liskov Substitution principle introduces reduced Coupling.
** Chapter Timestamps **
0:00 Welcome to Liskov Substitution Principle
1:15 Agenda of Liskov Substitution Principle Tutorial
2:21 Introduction to Liskov Substitution Principle
4:43 Real World Example of Liskov Substitution Principle
6:12 Java Code Example of Liskov Substitution Principle
12:27 Usage of Liskov Substitution Principle
13:05 Advantages of Liskov Substitution Principle
13:40 Summary of Liskov Substitution Principle
14:40 Next Video on Interface Segregation Principle
#solidprinciples #liskovsubstitution #liskovsubstitutionprinciple
** GIT Repository **
CodeOneDigest Solid Principles Example https://github.com/codeonedigest/soli...
** CHECK OUT OUR OTHER VIDEOS **
Spring boot project setup:
• Spring boot Proje...
Spring Boot Microservice with postgres database Project:
• Spring Boot Micro...
Prepare Docker file, Container and Build Image:
• Docker Tutorial f...
Deploy Docker Image AWS Elastic Container Service:
• Deploy Springboot...
Solid Principle Tutorial
• Solid Principles ...
** CHECK OUR PLAYLISTS **
Java Design Pattern Complete Tutorial
• Java Design Patte...
Spring Boot Complete Tutorial
• Spring Boot Tutor...
Docker Containers Complete Tutorial
• Cloud & Container...
Solid Principles and Object-Oriented Programming Concept and Design
• Solid Principles ...
** Acronyms **
OOP – Object Oriented Programming Languages
SRP – Single Responsibility Principle
OCP – Open Closed Principle
LSP – Liskov Substitution Principle
ISP – Interface Segregation Principle
DIP – Dependency Inversion Principle
COD – Code One Digest
** ABOUT OUR CHANNEL **
CodeOneDigest is a youtube channel that produces videos on programming languages, cloud and container technologies, Software design principles, Java frameworks in English and Hindi languages.
Check out our channel here:
/ @codeonedigest
Don’t forget to subscribe!
** OUR WEBSITE **
https://codeonedigest.wordpress.com/
** GET IN TOUCH **
Email us on codeonedigest@gmail.com
FOLLOW US ON SOCIAL - LIKE, SHARE & SUBSCRIBE
Get updates or reach out to Get updates on our Social Media Profiles!
Subscribe: https://bit.ly/3NeWQ8U
Youtube:
/ @codeonedigest
Twitter: https://twitter.com/codeonedigest
Facebook: https://www.facebook.com/codeonedigest
Instagram: https://www.instagram.com/codeonedigest/
Linkedin: https://www.linkedin.com/in/codeone-d...
Website: https://codeonedigest.wordpress.com/
Comments
Post a Comment