Re: Retrieving unnecessary data



On 2008-02-20 11:08:37 -0600, topmind <topmind@xxxxxxxxxxxxxxxx> said:



Robert Martin wrote:
On 2008-02-19 13:14:31 -0600, topmind <topmind@xxxxxxxxxxxxxxxx> said:

Evidence that OO makes testing easier?

Function f destroys the world when it is called. Function y calls
function f. How do I test function y? I hide f behind a polymorphic
interface called IF. I implement a fake version of f called MF. I
pass MF to y and tell y to do it's thing. Then I ask MF if f was
called. The world was not destroyed, and yet I know that y will call f.

One can also write a dummy stub function f,

Sure, and sometimes that would be a good choice. Other times the polymorphic interface would be a good choice.

or use a dummy database
(dummy world) for testing.

Ah, now that's an interesting concept. You mean a database that, for all intents and purposes, looks like a production database but isn't. You mean one that can be substutited for the production database according to the LSP. You mean...an object?

I think that's a very good idea.

--
Robert C. Martin (Uncle Bob)  | email: unclebob@xxxxxxxxxxxxxxxx
Object Mentor Inc.            | blog:  www.butunclebob.com
The Agile Transition Experts  | web:   www.objectmentor.com
800-338-6716                  |



.



Relevant Pages

  • Re: Retrieving unnecessary data
    ... How do I test function y? ... I implement a fake version of f called MF. ... polymorphic interface would be a good choice. ... looks like a production database but isn't. ...
    (comp.object)
  • Re: How read out own IP-address?
    ... you could take an existing interface, say `eth0', and make a new fake ... thats what I had in mind. ...
    (comp.unix.programmer)