Say I have:
interface Thing
{
GetThing();
}
class FastThing : Thing
{
public int GetThing()
{
return 1;
}
}
class SlowThing : Thing
{
public int GetThing()
{
return GetThingFromDatabase();
}
}
Is this a violation of the Liskov Substitution Principle?
GetThingFromDatabase()
is not slow enough to make this controversial.Factor4096BitPublicKey();return 1;
would make things a bit more interesting.FastThing
withSlowThing
, the LSP does not apply. If you add a comment toThing::GetThing
which says "Is very fast", the question can be discussed.