Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1105625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:39:44+00:00 2026-05-17T01:39:44+00:00

I recently read Michael C. Feathers’ book Working effectively with legacy code and came

  • 0

I recently read Michael C. Feathers’ book Working effectively with legacy code and came across the point where he mentioned a way to test the safety of automatic refactoring tools.

My question is: Are there any safe refactoring tools for the .net platform?; that means tools which only allow real refactorings and e.g. don’t allow the inline variable refactoring on the temp variable in the following example, or at least show a warning that I am changing logic.

class Program
{
    private static int _x;

    static void Main()
    {
        int temp = Test();
        for (int i = 0; i < 10; ++i)
        {
            Console.WriteLine(temp);
        }
        Console.ReadKey();
    }


    private static int Test()
    {
        return ++_x;
    }
}

I’ve tested this example on the refactoring tools Resharper and Coderush + Refactor pro with the latest versions and both failed the test and allowed the refactoring to:

class Program
{
    private static int _x;

    static void Main()
    {
        for (int i = 0; i < 10; ++i)
        {
            Console.WriteLine(Test());
        }
        Console.ReadKey();
    }

    private static int Test()
    {
        return ++_x;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:39:44+00:00Added an answer on May 17, 2026 at 1:39 am

    To be really safe with automated refactorings is very hard.

    When we first introduced refactorings in Visual C#, we asked ourselves this question: do our refactorings need to get things completely right all the time, or should we allow them to make mistakes in certain cases?

    To be right all the time would require a lot of programmer effort, meaning we’d only get a few refactorings in the box. It would also make the refactorings slow, as they’d spend a lot of time in validation.

    Allowing them to make mistakes would make them useless for any teams that didn’t have great automated test coverage. TDD teams have good tests, but that’s only one portion of the Visual Studio user base. We didn’t want to make features that we had to tell people not to use!

    TDD teams would catch mistakes quickly, but they would learn just as quickly not to trust our refactoring tools. They’d hesitate to use them, and seek other solutions much of the time (find-and-replace instead of Rename).

    Also, as the C# team, we were in a good position to make high-fidelity refactorings. We had a unique advantage, with the C# language designers and compiler team just down the hall. We knew we should play to our strengths.

    So, we decided to make fewer high-quality refactorings, instead of lots of refactorings that weren’t as reliable. Today there are 6.

    Visual Studio Refactorings

    Looking back, I wish we had only done Rename, Extract Method, and Introduce Local Variable. Those last two are almost the same, implementation-wise. The 3 Parameter refactorings (there used to be a 7th, Promote Local Variable to Parameter, but it was cut in VS2010) were a ton of work to get right, and probably weren’t worth it.

    My recommendation is to do TDD, giving you a great collection of tests so you can refactor safely, whether you use a tool or do it by hand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently read in Code Complete that the recommended way of handling expressions that
I recently read the the following SO question. What's the best way to store
I recently read through Code Complete, and it recommends that I create a project
I recently read a text regarding buffer overflows that mentioned that setting breakpoints can
I recently read this post: Floating point vs integer calculations on modern hardware and
A textbook I recently read discussed row major & column major arrays. The book
I recently read about a new Google-code hosted (open source) project from Google that
I recently read Ayende's blog post on automatic registration working with XML Configuration. I
I recently read that a method involving hashing could be a good way to
I recently read (and unfortunately forgot where), that the best way to write operator=

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.