Posts Refactoring to debut in VB 2005!
Post
Cancel

Refactoring to debut in VB 2005!

Yes, you read that correctly!  VB 2005 will have full support for refactoring in the form of a community edition of Refactor! for Visual Basic 2005.  Refactoring tools include:

  • Rename (Native to VB 2005, not a part of Refactor!.)
  • Reorder Parameters
  • Extract Method
  • Extract Property
  • Create Overload
  • Surrounds With
  • Encapsulate Field
  • Reverse Conditional
  • Simplify expression
  • Introduce Local
  • Introduce constant
  • Inline Temp
  • Replace Temp with Query
  • Split Temporary Variable
  • Move initialization to declaration
  • Split initialization from declaration
  • Move declaration near reference
  • </UL>

    Now, to compare this to what is being included in C#:

    • Extract Method
    • Encapsulate Field
    • Extract Interface
    • Reorder Parameters
    • Remove Parameters
    • Rename
    • Promote Local Variable to Parameter
    • </UL>

      I've bolded the refactoring tools that are available in both languages.  Now some people might focus on the fact that there are some in C# that aren't in VB.  And to some degree, I agree that that VB should not only be equal in this regard, but should go above and beyond.  After all, we are only talking about adding 3 more refactoring tools to accomplish this.  At the very least, why not add Remove Parameters and Promote Local Variable to Parameter since they are within the same family of task as Reorder Parameters.

      Now, just seeing the functional equivalent between the two isn't the whole story.  The approach taken by Refactor! is worlds different than the C# approach.  Refactor! is integral to the development environment.  I hear how C# is all about making coding easier, but once you see Refactor! in action, you'll have to agree that the C# implementation pales in comparison.  There are no modal dialogs with Refactor!, it's as if it's an integral part of the coding experience. 

      In addition, Refactor! gives you several ways to initiate each refactoring tool and is completely context sensitive. For example, in C#, I can right click on a property of a method and select the Refactor menu item which expands into the refactoring tools available.  Why is the Promote Local Variable to Parameter available?  It's not a local variable.  The menus aren't context sensitive, thus removing the whole idea behind what a context sensitive menu is designed for.  In addition to Refactor! being context sensitive menus being... ummm... context sensitive; they also leverage the smart tag functionality and are accessible via a context aware keyboard shortcut (CTRL+~).

      Wait, there's more!  This next feature is really more of a nicety rather than a necessity.  However, it really does improve the overall coding experience.  Refactor! is very, very visual.  For example, when using Reorder Parameter, you actually see the variables move from one position to the other... it's animated.  Once you commit, you then proceed to walk through the code (in the code viewer, not a modal dialog).  If you cancel, instead of presenting you with an box stating that you've canceled, the code window shows a watermark in very large letters stating that “Reorder Parameters Canceled”.

      Wait!  There's EVEN MORE!  Let's say you have a chunk of code within a method.  You can mark this code, copy it to the clipboard and once you paste it outside of a method (within the class), it will automatically initiate the Extract Method tool.  How cool is that?

      So what about the “missing” refactoring tools?  If you register the community edition, you will gain the following:

      • Create Method Contract
      • String Composition to String.Format
      • Rename Local
      • Safe Rename
      • “And more refactorings as they are made available by Developer Express!“
      • </UL>

        If that's not enough, purchasing the full version will gain you not only the ones “missing”, but additional ones to yet to be determined.  However, after speaking with the developers of the tool, Remove Parameters and Promote Local Variable to Parameter will be available (as a definite) in the Pro version and a subset what will be coming in the Pro version will be made available to the community version (as to what that will include, that hasn't been decided upon).

        To me, when I envisioned what refactoring should be in VB, this product comes very close to hitting the head on the nail.  I'm simply amazed!

        To read more, you can go directly to the announcement on MSDN which contains a breakdown of some of the features and has some really cool screen shots of the tools in action.

        (Note: Just so the C# folks don't feel left out, Refactor! Pro will be available for C#... just not free.  Also, I should note that Refactor! for VB 2005 does not work with the Express Editions, as they don't support the VSIP.)

        [update] If you aren't sure what refactoring is or would just like to see a demo of this feature, there is now a 30 second demo (commercial) available.  You really have to see it to appreciate it and it's great that they've made this video available.

        [update] Can't get enough?  How about over 15 minutes worth of demonstration?  Carl Franklin hosts Mark Miller (Developer Express) with a set of video demonstrations (Part 1 and Part 2).

This post is licensed under CC BY 4.0 by the author.