basic OOP coupling question

basic OOP coupling question

Post by Paul Sinnet » Fri, 31 Aug 2001 14:10:32



Quote:> If, in order to write a test case, I must make an otherwise private
> variable public, then I will make it public and communicate my intent
> in some other way.

If you are exposing the internals for testing purposes then you are
writing tests that are dependent on the implementation details.

Doesn't this impede refactoring since you would have to change the tests
if you changed only the implementation details?

 
 
 

basic OOP coupling question

Post by Ron Jeffrie » Fri, 31 Aug 2001 20:21:21


On Thu, 30 Aug 2001 06:10:32 +0100, "Paul Sinnett"


>> If, in order to write a test case, I must make an otherwise private
>> variable public, then I will make it public and communicate my intent
>> in some other way.

>If you are exposing the internals for testing purposes then you are
>writing tests that are dependent on the implementation details.

Yes, though the kind of exposing one does is usually just to get
access to internal state, not to do anything _really_ hideous. But ...

Quote:

>Doesn't this impede refactoring since you would have to change the tests
>if you changed only the implementation details?

To a degree it does. So when I am feeling the urge to rip open an
object to find out what it is doing, I take that as an indication
suggesting that I need a better way. Often, paying attention to that
indication produces a better idea. But if I don't get a better idea,
then I _do_ put in the access for the test. If we do have to refactor
the code (and tests), we'll probably see then what parts of the object
needed to be pulled out for separate testing. And if not ... I'd
rather have the tests and do a little extra work.

Regards,

Ronald E Jeffries
http://www.XProgramming.com
http://www.objectmentor.com

 
 
 

basic OOP coupling question

Post by Robert C. Mart » Sun, 02 Sep 2001 06:36:13


On Thu, 30 Aug 2001 06:10:32 +0100, "Paul Sinnett"


>> If, in order to write a test case, I must make an otherwise private
>> variable public, then I will make it public and communicate my intent
>> in some other way.

>If you are exposing the internals for testing purposes then you are
>writing tests that are dependent on the implementation details.

Yes.

Quote:

>Doesn't this impede refactoring since you would have to change the tests
>if you changed only the implementation details?

Yes.  But having the test is more important than the potential of
impeding a refactoring, IMHO.

Robert C. Martin    | "Uncle Bob"              | Software Consultants

PO Box 5757         | Tel: (800) 338-6716      | your projects done.
565 Lakeview Pkwy   | Fax: (847) 573-1658      | www.objectmentor.com
Suite 135           |                          | www.XProgramming.com
Vernon Hills, IL,   | Training and Mentoring   | www.junit.org
60061               | OO, XP, Java, C++, Python|

"One of the great commandments of science is:
    'Mistrust arguments from authority.'" -- Carl Sagan