[Prev][Next][Index][Thread]
Re: Proxy objects [was: Re: [Q]Why are all classes rooted by <object>]
-
To: info-dylan@ai.mit.edu
-
Subject: Re: Proxy objects [was: Re: [Q]Why are all classes rooted by <object>]
-
From: Michael Schuerig <schuerig@acm.org>
-
Date: Mon, 6 Aug 2001 16:45:02 -0400 (EDT)
-
Organization: -
-
References: <200108061800.OAA26517@life.ai.mit.edu>
-
User-Agent: KNode/0.5.6
-
Xref: traf.lcs.mit.edu comp.lang.dylan:13566
Jeff Dalton wrote:
>> > In Dylan you have to do pretty
>> > much the same as in C++/Java/etc.: write a wrapper class with a
>> > bunch of "forwarding" methods. ...
>
> But see
>
> http://java.sun.com/j2se/1.3/docs/api/java/lang/reflect/Proxy.html
A very cool use of Java proxy classes is exemplified by EasyMock
http://tammofreese.de/easymock/index.html
<quote>
Mock objects emulate parts of the behaviour of domain code, and are
able to check whether they are used as defined. Domain classes can be
tested independently by simulating the classes they use with mock
objects.
</quote>
The idea is, that in a test case you prime a mock object -- a stand-in
that for some finite set of cases acts as if it was the real thing --
with the expected calls and responses. Then, the mock object is passed
to the code to be tested and it records if it is called appropriately.
Michael