Does inheritance from a class with unused methods violates the interface segregation principle?
For example:
abstract class Base
{
public void Receive(int n)
{
// . . . (some important work)
OnMsg(n.ToString());
}
protected abstract void OnMsg(string msg);
}
class Concrete : Base
{
protected override void OnMsg(string msg)
{
Console.WriteLine("Msg: " + msg);
}
}
Concrete depends on method Base.Receive(int n), but it never uses it.
UPD
Definition I use:
ISP states that no client should be forced to depend on methods it does not use.
OnMsgis fromReceive. I need this inheritance to project incoming data (int n) toConcrete's interface which usesstring msg. In real example there's some more complex work than justToString()template design patternhere :)