A froggy visitor
From CSSEMediaWiki
Revision as of 02:24, 16 July 2010 by Colin Fagg (Talk | contribs)
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.