Visual Studio 2003 to 2005 Application Conversion
My first Visual Studio (VS) 2003 to 2005 C# application conversion went pretty smoothly. Time required: 90 minutes. The application is a data processing, automation utility I use for report writing on a healthcare information system.
New feature I like: VS 2005 supports basic XP refactoring (rename, extract method, encapsulate field, extract interface, promote local variable to parameter, remove & reorder parameters).
For the past year I've focused on writing code in a hierchical database language called Magic. I didn't realize all the generic concepts I'd learned til I stepped into this C# code from a year ago. Reading Martin Fowler's book on Refactoring has, as he promised made me a better programmer already.
// Automatic Build and Copy
if(chkAutomaticBuildCopy.Checked==true)
{
RegWriter.WriteRegistryInfo("AutomaticBuildCopy", "true");
}
else
{
RegWriter.WriteRegistryInfo("AutomaticBuildCopy", "false");
}
The code above & below demonstrates just one of many of things I'll now refactor and do just a little differently:
// Automatic Build and Copy
strRegistryKey = "AutomaticBuildCopy";
RegWriter.WriteRegistryInfo(strRegistryKey, chkAutomaticBuildCopy.Checked.ToString());
The Extract Method in VS 2005 is pretty good, but not perfect. Variables not needed due to refactoring were included as unnecessary parameters when I performed the Extract Method routine. You still have to know what you are doing.
So far I really enjoy refactoring code in VS 2005!

1 Comments:
Couple of comments...
First of all, C# requires all code paths to return a value if it's not a void function. This is true in 2003 and 2005. VB.NET does not.
In C#, all variables must be initialized... but this does not prevent null reference excpetions because you can initialize a variable with null. This is true in 2003 and 2005. You just have to explicitely set it to null in code instead of letting the compiler do it for you. VB.NET will do this implicitely for you.
Post a Comment
Links to this post:
Create a Link
<< Home