Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
OOP

Liskov Substitution Principle

Ensure subclasses can replace parent types without breaking callers.

Liskov Substitution Principle — a practical guide to LSP SOLID with clear examples you can reuse in real projects.

OOP Tutorial Series (49/65). Prefer one article? Read the complete OOP tutorial.

Short description

If code expects a `Bird`, a subclass should not surprise it (e.g., by throwing on `fly()` when flying was assumed).

LSP tip

Subtypes must honor parent contracts
Don't strengthen preconditions unexpectedly
Prefer separate interfaces when behaviors diverge

Leave a reply

Your email address will not be published. Required fields are marked *