Frogs design

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(Added broken heuristics 5.12, 5.13)
Line 24: Line 24:
 
** 5.1 [[Inheritance for specialization]]: A toad is not a frog; it's [[Avoid_inheritance_for_implementation|inheritance for implementation]].
 
** 5.1 [[Inheritance for specialization]]: A toad is not a frog; it's [[Avoid_inheritance_for_implementation|inheritance for implementation]].
 
** 5.17 [[Avoid no-op overrides]]: The ''hop'' and ''swim'' methods of ''Egg'' do nothing.
 
** 5.17 [[Avoid no-op overrides]]: The ''hop'' and ''swim'' methods of ''Egg'' do nothing.
 +
** 5.12 [[Beware type switches]]: ''Frog'' has a type attribute which is used in ''swim()'' (5.13 as well?)
  
 
* The biologist should have the saute method, not the frog itself.
 
* The biologist should have the saute method, not the frog itself.

Revision as of 03:02, 20 July 2009

An OO model of frogs. This beautiful design appeared in the 2004 427 exam.

Frogs.gif

Design notes

  • This design models the lifecycles of Frogs.
  • A Frog begins life as an Egg, grows into a Tadpole and then an AdultFrog.
  • A FrogBrain belongs to a Frog and manages its behaviour.
  • There is one Biologist, Igor, who sometimes moves Frogs around. Igor has been known to fry their legs in white wine.
  • Toads don’t have the same lifecycle as Frogs, but they look and act a lot like Frogs.
  • Toads eat AdultFrogs.

Broken heuristics

  • The biologist should have the saute method, not the frog itself.
Personal tools