A froggy visitor
From CSSEMediaWiki
(Difference between revisions)
John Hofman (Talk | contribs) |
Colin Fagg (Talk | contribs) |
||
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:
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.