Skip to Content
Architectural Patterns
book

Architectural Patterns

by Anupama Murali, Pethuru Raj, Harihara Subramanian J, Pethuru Raj Chelliah
December 2017
Intermediate to advanced
468 pages
13h 12m
English
Packt Publishing
Content preview from Architectural Patterns

Liskov substitution principle (LSP) – SOLID

This principle states that any of the child classes should not break the parent class's type definitions or, in other words, derived classes should be substitutable for their base classes.

Let's first understand the violation of substitution principle, and then we see how we can resolve the same by taking our earlier example of account classes as LSP is a prime enabler of OCP:

Let's assume that withdrawal from kids account is not allowed, unlike general account. As you see in the preceding class diagram, a withdraw method in the kids account class is a breach of LSP, so by introducing other withdrawable ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Software Architecture Patterns

Software Architecture Patterns

Mark Richards
Design It!

Design It!

Michael Keeling

Publisher Resources

ISBN: 9781787287495Other