From: J. X. <sou...@ma...> - 2003-12-18 15:11:26
|
Quoting Nat Pryce <nat...@b1...>: > Your object should make use of interfaces that make sense to it, not > that are defined by technology that you have chosen. This is what mock > objects are good for: in TDD they drive the design of an object's > *required* interfaces. Sometimes, it does make sense to define an abstract interface between a client and its vendor, but not all the time, especially when the usage of the vendor requires strong assumptions. In this castor case, castor's (rather intrusive) usage paradigm has made a lot of impact on my code, e.g., all the classes handled by the marshalling engine must have either public getters/setters or have their own castor-dependent handlers. Another example is that I had to make special wrapper classes simply because the XML unmarshaller cannot effectively unmarshal a map. From the design point of view, it would be just illusional to have an "un/marshaller interface" and pretend to have the ability to "plug in" another un/marshaller. Well, my question is, then, do mock objects drive, or do they actually *force* the design? Following this pattern, wouldn't I have to define interfaces for every 3rd party class I use that does not support a factory, in order to be able to plug in my own mocked version of those classes? --J.X. > > Your object needs to unmarshall some data from some input stream. The > interface should express that. An implementation of the interface can > use the castor API. But if you drive the design of the interface from > the needs of your object, not from your choice of castor, then it will > be easy to change your choice of XML API later if you want. Using mock > objects to drive the design of the interactions between your objects > will naturally lead to such "flex points" in your design. > > Cheers, > Nat. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > |