Re: Ambiguous Refactoring Solution

Adam Sroka <[email protected]>
Newsgroups gmane.comp.programming.refactoring
Message-ID <[email protected]>
On Thu, Sep 24, 2009 at 4:24 PM, Richard <[email protected]> wrote:
>
>
>
> In article <[email protected]>,
>
> Adam Sroka <[email protected]> writes:
>
> > I think you may be misunderstanding what I mean when I say to cover
> > with tests before you refactor.
>
> No, I don't misunderstand at all.
>

You repeatedly said "Do you write tests for [some] refactoring?" I do
not write tests for any refactoring. That is not /why/ I write tests.
I write tests to *prove* deterministically, that the code does what I
intend it to do. I can then improve its design in any way I see fit so
long as I can still *prove* that it works. The latter has many
additional benefits, but it is not /why/ I do it.

> You didn't really answer any of the questions I posted, but instead
> assumed I didn't understand what you were saying.
>

I answered one of your questions in some detail. I didn't answer the
others directly, because they were of the form "Do you write tests for
[some] refactoring?" See above.

> There are plenty of times where I have enough confidence in automated
> refactorings that I don't feel the need to write a covering test
> before performing the refactoring. Rename and Extract Method are the
> two most common refactorings used by me, and probably by anyone who
> refactors. With good automated support for these refactorings, I
> don't feel I'm "living dangerously" by applying them from my IDE on
> code that is uncovered by tests.

Rename and Extract Method are barely refactoring by themselves
(Especially if "Extract Method" merely produces a local private method
as it commonly does.)

However, if you are going to significantly change the design of your
code it would be useful to know that it still does what you intend it
to do in all of the ways that you intend it to do it. It seems to me
that automated testing is a quick, relatively inexpensive way to make
sure. Why wouldn't you do it?

Moreover, as a programmer, why would you not automate any repetitive
task? Why would you intentionally do something that must, by
definition, be done over and over again (e.g. testing, building,
deploying, etc.) manually?


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

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.