Skip to content

Liskov: Subclass shouldn't strengthen pre-conditions #10

@ResponsiblyUnranked

Description

@ResponsiblyUnranked

A subclass shouldn’t strengthen pre-conditions:

  • If a superclass method is allowed to take any integer but the subclass method (that overrides the superclass) throws an exception for negative integers, then you have strengthened the pre-conditions
  • You won’t be able to swap the superclass and subclass without the possibility of breaking the code

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions