Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • +1 for "if your dog does fly, then you should probably stop throwing him out of the window". :) Commented Dec 29, 2010 at 20:39
  • Beyond the question of what the class should represent, what does an instance represent? If one regards SeesFood as a characteristic of DogEyes, Bark as something done by a DogVoice, and Eat as something done by a DogMouth, then logic like if (dog.SeesFood) dog.Eat(); else dog.Bark(); will become if (eyes.SeesFood) mouth.Eat(); else voice.Bark();, losing any sense of identity that eyes, mouth, and voice are all connected to a single entitity. Commented Mar 25, 2014 at 19:20
  • @supercat it's a fair point, though context is important. If the code you mention is within the Dog class, then it's probably Dog-related. If not, then you would probably end up with something like myDog.Eyes.SeesFood rather than just eyes.SeesFood. Another possibility is that Dog exposes the ISee interface which demands the Dog.Eyes property and the SeesFood method. Commented Apr 1, 2014 at 13:32
  • @JohnL: If the actual mechanics of seeing are handled by a dog's eyes, in essentially the same way as by a cat's or a zebra's, then it may make sense to have the mechanics handled by an Eye class, but a dog should "see" using its eyes, rather than merely having eyes that can see. A dog isn't an eye, but nor is it simply an eye-holder. It is a "thing that can [at least try to] see", and should be described via interface as being such. Even a blind dog can be asked if it sees food; it won't be very useful, since the dog will always say "no", but there's no harm in asking. Commented Apr 1, 2014 at 18:04
  • Then you'd use the ISee interface like I describe in my comment. Commented Apr 2, 2014 at 9:16