Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 746 Bytes

4_ISP_code_refactor.md

File metadata and controls

35 lines (26 loc) · 746 Bytes

refactored interfaces to be segregated:

interface IWalkingBird {
  void Walk();
}

interface IFlyingBird {
  void Fly();
}

interface ITalkingBird {
  void Talk();
}

Now the birds only need to implement the interfaces they care about:

class Dove : IWalkingBird, IFlyingBird {
  void Walk() { return "slow"; }
  void Fly() { return "low"; }
}

class Eagle : IFlyingBird {
  void Fly() { return "soar"; }
}

class Ostrich : IWalkingBird {
  void Walk() { return "fast"; }
}

class Parrot : IWalkingBird, ITalkingBird {
  void Walk() { return "caged"; }
  void Talk() { return "polly"; }
}

« back to readme.md