Re: Ambiguous Refactoring Solution

Olof Bjarnason <[email protected]>
Newsgroups gmane.comp.programming.refactoring
Message-ID <[email protected]>
2009/9/25 Richard <[email protected]>
>
>
>
> In article <[email protected]>,
>
> Carfield Yim <[email protected]> writes:
>
> > Sometime we may like to remove variable that we think we don't use anymore,=
> > like
> >
> > int dog =3D createDog();
> >
> > however in method createDog(), it may do more than just return a dog
> > and remove that line cause somthing else fail.
> >
> > With unit test we can prevent problem like that, of course if you
> > don't you will make mistake then it is fine
>
> ...and without a unit test, you would do things like inspect createDog
> for side-effects that must occur, or you wouldn't remove the whole
> statement, just the variable declaration because side effects may be
> possible.
>
> Or, holy shit batman!, you could test it manually.

Richard,

That statement, "Or, holy shit batman!, you could test it manually.",
makes me wonder how much unit testing you have done..

The whole deal with unit testing is the realization that humans are lazy beings.

Of course, everything that is auto-testable is also manually testable
via debuggers.

The distinction isn't what is possible to test using auto-tests vs.
manual-tests.

The distinction is the speed, effort and accuracy such with which such
things are done.

Since humans are lazy, they tend to skip things they deem unnecessary.
Or tiresome. Like performing every single step of a 10 instructions
long routine - also known as manually testing the behaviour of some
piece of a system, for the gazillionth time the same day. Just watch
your non-TDD:ing collegues a regular work day. How much time do they
spend designing? How much time debugging/clicking around?

Doing routine manual testing, the case needed when doing refactoring
of legacy code (code without tests) is:

1) error-prone
2) slow
3) boring

Now contrast with refactoring+running automatic tests on some part of
a system. It is

1) accurate
2) fast
3) not-so-boring

And the act of writing those unit tests is actually both technically
rewarding and fun.

I recommend Michael Feathers bible on the topic, "Working Efficiently
with Legacy Code".

>
> --
> "The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
> <http://legalizeadulthood.wordpress.com/the-direct3d-graphics-pipeline/>
>
> Legalize Adulthood! <http://legalizeadulthood.wordpress.com>
> 


--
twitter.com/olofb
olofb.wordpress.com
olofb.wordpress.com/tag/english


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.