Skip to main content
PreparationZone Logo
PrepZone

Liskov Substitution Traps

Subtypes must honour the parent's promise — or the hierarchy is lying.

Pass checkpoint below

Why this matters

  • Contract definition — detailed pointwise breakdown in the section below.
  • Square-rectangle trap — detailed pointwise breakdown in the section below.
  • Pre/post conditions — detailed pointwise breakdown in the section below.
  • CampusOS payment types — detailed pointwise breakdown in the section below.
  • SOLID is scored as refactor skill, not acronym recall.
SRPOne reason to change
OCPExtend, don't modify
LSPSubtypes substitutable
ISPSmall interfaces
DIPDepend on abstractions
Each principle maps to a class-design smell interviewers probe.

Overview

Subtypes must honour the parent's promise — or the hierarchy is lying. Study each section below in order — every list is interview-ready reference material.

Contract definition

Points to cover

  • Definition — what Contract definition means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 3 sections

  • Square-rectangle trap
  • Pre/post conditions
  • CampusOS payment types

Test yourself

Answer these before moving on — recall is what makes it stick.