A froggy visitor

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
Line 10: Line 10:
  
 
* If the frog did not know how to export itself then another class would need internal access to achieve this. However, this will break the [[Encapsulation boundary]].
 
* If the frog did not know how to export itself then another class would need internal access to achieve this. However, this will break the [[Encapsulation boundary]].
 +
 +
Riel states [[Model the real world]] is often violated for keeping related data and behaviour in one place so the current exportXML may very well be the lesser of these two evils.

Revision as of 02:24, 16 July 2010

Homework excercise for us!

This exercise was introduced during a discussion about this Frogs design example. The question was raised concerning the "exportXML()" method of the frog class:

Frog export exercise.gif

Is this method good, evil, or the lesser of two evils?

  • This method contradicts the Model the real world maxim. A frog does not know about exporting itself and should not be able to.
  • If the frog did not know how to export itself then another class would need internal access to achieve this. However, this will break the Encapsulation boundary.

Riel states Model the real world is often violated for keeping related data and behaviour in one place so the current exportXML may very well be the lesser of these two evils.

Personal tools