Steven Giesel 3/5/2023

Is a square a rectangle? Liskov substitution principle in action

Read Original

This technical article uses the geometric question 'Is a square a rectangle?' to explain the Liskov Substitution Principle (LSP) in SOLID design. It demonstrates with C# code how a Square class inheriting from Rectangle can violate LSP by altering the behavior of parent class methods, leading to unexpected results and broken assumptions in code.

Is a square a rectangle? Liskov substitution principle in action

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

1
The Beautiful Web
Jens Oliver Meiert 2 votes
3
LLM Use in the Python Source Code
Miguel Grinberg 1 votes
4
Wagon’s algorithm in Python
John D. Cook 1 votes