The Artima Developer Community
Sponsored Link

Agile Buzz Forum
VS2005 beta refactorings - under-impressed

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
VS2005 beta refactorings - under-impressed Posted: Feb 25, 2005 11:19 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: VS2005 beta refactorings - under-impressed
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From David Buck - Blog

Advertisement

The VisualStudio 2005 beta available from Microsoft proudly lists Refactorings in its list of new features. I installed it and I've been playing with it for a while. Maybe I'm spoiled by the Smalltalk Refactoring Browser, but I'm not impressed by the refactorings in .NET

First, the refactorings included are

  • Extract Method
  • Rename
  • Encapsulate Field (equivalent to Abstract)
  • Extract Interface
  • Promote Local Variable to Parameter
  • Remove Parameters
  • Reorder Parameters

Where are the rest of the refactorings?

  • Extract to Temporary
  • Push up
  • Push down
  • Extract to Component
  • Inline Method
  • Inline all self sends
  • Create subclass
  • Convert to sibling
  • Protect

I suppose it's a good start, but I for one am used to having a whole lot more refactorings at my disposal. Maybe we'll get more in the next version.

All the refactoring menu items are enabled all the time. This means that you don't know that the refactoring is inappropriate for the selected code until you try the menu item and it fails. This is just annoying.

The extract method refactoring doesn't seem to be smart enough to detect that there already exists a method that does the same job. This is a very handy feature of the Smalltalk Refactoring browser.

The cardinal rule of a refactoring is that it musn't change existing functionality. With only a little work, I was able to make VS2005 refactoring break this rule. This one hole completely destroys my confidence in the tool. (I understand that I'm working with a beta, but I hope they fix it before the final release).

The code that broke the refactoring is:

    public class Class1
    {
        protected int var1 = 0;

        public virtual int Test2()
        {
            return Test() * 5;
        }

        public virtual int Test()
        {
            return var1 + 2;
        }

    }

    public class Class2 : Class1
    {
        public override int Test()
        {
            int var1 = 5;
            return var1 * 10;
        }

When you run Test2, it returns 10. I selected the variable var1 in the Test method of Class2 and selected "Promote temporary to Parameter". Here's the result:

    public class Class1
    {
        protected int var1 = 0;

        public virtual int Test2()
        {
            return Test(5) * 5;
        }

        public virtual int Test(int var1)
        {
            return var1 + 2;
        }

    }

    public class Class2 : Class1
    {
        public override int Test(int var1)
        {

            return var1 * 10;
        }

Now when you run Test2, it returns 35. In my mind, the Test method in the superclass doesn't work the way it did before.

So it seems that these refactorings aren't complete, and aren't even correct. That's not a good sign.

Read: VS2005 beta refactorings - under-impressed

Topic: The reading backlog Previous Topic   Next Topic Topic: ExtraCatalogs

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use