Eroxl's Notes
Liskov Substitution Principle

The Liskov substitution principle states whether or not a subclass can be substituted for its superclass.

Informally the Liskov substitution principle states the following 3 rules

  1. Preconditions cannot be strengthened in the subclass's methods
  2. Postconditions cannot be weakened in the subclass's methods
  3. Invariants cannot be weakened in the subclass.

Effectively this means that any methods in a subclass must minimally accept the same inputs, but can accept more inputs as long as they still accept the same inputs, and must output the same outputs but can output less outputs as long as their still in the range of permissible outputs of their superclass.

Additionally, if there are no changes to the preconditions, postconditions and invariants the Liskov substitution principle is also held.