O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

LSP

The LSP states that objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

The LSP is essentially a restricted instance of subtyping, which aims to guarantee semantic portability across class hierarchies. Portability is achieved by ensuring that whatever is true of a base type is also true of all subtypes. Subclasses must not strengthen preconditions. They must accept all input and initial states that the base class accepts, and subclasses must not weaken post-conditions. Behavioral expectations declared by the super class must be met by the subclass. These characteristics cannot be enforced by the type system alone.

The LSP as a relation of inheritance is thus deceptive, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required