Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 987 Bytes

4_ISP_code_problem.md

File metadata and controls

37 lines (29 loc) · 987 Bytes

the below example shows a Bird interface that does a lot:

interface IBird {
  void Walk();
  void Fly();
  void Talk();
}

Now every bird that we implement, will need to be able to do all of these things.

class Dove : IBird {
  void Walk() { return "slow"; }
  void Fly() { return "low"; }
  void Talk() { return ""; }
}

class Eagle : IBird {
  void Walk() { return "seldom"; }
  void Fly() { return "soar"; }
  void Talk() { return ""; }
}

class Ostrich : IBird {
  void Walk() { return "fast"; }
  void Fly() { return ""; }
  void Talk() { return ""; }
}

class Parrot : IBird {
  void Walk() { return "caged"; }
  void Fly() { return ""; }
  void Talk() { return "polly"; }
}    

We are "forcing" all future birds to do all these things. Should we force this?

« back to readme.md | view the refactored code »