The Square-Rectangle Problem @ChristopherOkhravi
The Square-Rectangle Problem  @ChristopherOkhravi
Uploaded March 2024 | Updated November 2026, 5 days ago
The infamous Square-Rectangle Problem is a great way to understand why Liskov's Substitution Principle is important. Do you know the answer to the problem?

💚 BUY MY BOOK:
theobjectorientedway.com

▶️ Watch this next:
youtu.be/7hXi0N1oWFU

00:00 The Problem
01:08 Defining Rectangle
01:35 Using Rectangle
02:16 Defining Square
02:37 Using Square
03:27 Overriding methods
04:39 Violating the super type
09:09 Question
09:27 Takeaway
The Square-Rectangle ProblemVariance and FruitsSubtypes Must Replace ConditionalsComposite Pattern DefinitionHigh Level Iterators replace Foreach | Code Walks 035Works VS ValuableRules Have Reasons (Always Ask Why)Reactive Programming from Scratch (JavaScript) - Ep3Impossible Is BetterDifferent algorithms or different values?Refactoring Attacks (by replacing conditionals with polymorphism)Depend on Abstractions not Concretions (Framework)
Christopher Okhravi |

The Square-Rectangle Problem

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER