Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Liskov substitution

The third principle from SOLID that we will be exploring is the Liskov substitution principle (LSP). It was introduced by Barbara Liskov in 1987 while delivering a keynote session at the Object-Oriented Programming Systems, Languages, and Applications (OOPSLA) conference [22]. The formal definition of LSP is as follows:

If, for each object, O1 of type S there is an object O2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when O1 is substituted for O2, then S is a subtype of T.

In layman's terms, two types are substitutable if their exhibited behavior follows exactly the same contract, thereby making it impossible for callers to distinguish between them. Thinking in pure OO ...

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

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content