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