Monday, March 28, 2005

Wake Up to VS.Net 2005

In their own words, We have just released a glorious beast onto the world - Beta 1 of Visual Studio 2005.Even VS 2005 is in its infancy, but it has got some very useful capabilities this time those may be useful to increase individual productivity by many folds. There are some new features in VS IDE. The most prominent one is the use of partial classes. Other features I will discuss as we go ahead.I am going to use Express Editions of different products to show the new changes.

Before diving to any thing, I bring up one important point to you. After installing .Net Framework 2.0 Beta your existing applications may break, particularly Web Applications. Why because, when .Net Framework 2.0 is installed, it sets active ASP.Net version to 2.0. To fix that go to Default Web Site Propertiesdialog box and set the ASP.Net version back to 1.1 or 1.0 as opposed to 2.0.

Default Web Site Properties

Now while I am dealing with ASP.Net things, I would like to mention one another small change. Now you can change your Machine configuration and Web configuration files directly from Default Web Site property dialog box or from your web sites property dialog box.

ASP.Net Configuration Settings

Now we will look into some other new improved areas in VS 2005. Before going ahead you would like to visit the following link to see what is no more backward compatible:
http://www.gotdotnet.com/team/changeinfo/Backwards1.1to2.0/default.aspx

The prominent change I found in VS 2005 is support for Partial Classes. Now you can split your classes into multiple files. In previous versionswe were forced to implement a class into single file, irrespective of how large it is. In that case it was developers responsibility to write code in a sensible manner. Now with the help of partial classes you can write one particular section of code into one file and other one to other file. It is compilers job to merge all those implementation split into several files. We as developers have to implement partial class with the same name in all files then only compiler will be able to pick up correct definitions to merge into one class definition.Take a look into following example:
partial class Demonstration //Demonstration.cs
{        
public Demonstration ()
{
InitializeComponent();
}
}


partial class Demonstration //Implementation.cs     
{        
private voidInitializeComponent()        
{            

//Implementation Goes Here        
}    
}

Code of both the classes will be merged while compiling. In case of C# project, your code will be in FormName.cs file and control related information would be in FormName.Design.cs. The same is in case of VB 2005.

I found Partial class is the only common feature in VS 2005 through out the languages. All other features are specific to languages. Like in C# there is a new IDE feature called Refactoring. Basically refactoring means enhancing the existing design of your code. Refactoring is the art to make your code more readable, performance oriented and adhering to best OO practices. There are seven refactoring features as given below:

Extract Method - Allow to create a new method based on selected code.
Encapsulate Field - This turns a public field to a private field encapsulated by .Net property.
Extract Interface - Defines a new interface type.
Reorder Parameters - Provides a way to reorder member arguments.
Remove Parameters - Removes a given argument
Rename - Renames the provided code token.
Promote Local Variable to Parameter - Moves a local variable to the parameter set of the defining method

I will demonstrate, how to Rename a method. Select the method you want to rename and select Rename from either Refactor menu or from context menu.

Refactoring

VS 2005 will ask you for a new name for particular code token. Instead of blindly renaming, VS 2005 will show you the predicted changesin following manner:

Preview Changes

To read more about Refactoring go through following link:
http://msdn.microsoft.com/vcsharp/default.aspx?pull=/library/en-us/dnvs05/html/VS05_refac.asp

There are whole lot of changes in C# at language leve. Some major changes done to this finest language are Generics, Iterators and Anonymous methods. However these things are now supported at CLR level, that means all langauge will enjoy these new features. I think these topics are vast enough in themselve and need separate treatement. I will not deal with these things right now.

However I will show you one amazing enhancement in VB 2005. VB developers will just love this fetaure. This is called My. This fetaure is implemented under My namespace. My provides you full control over your computer resources, user identities and not to say on your application. Suppose you want whether you are connected to network or your mouse is working or not, you can get all these information using My.

My

You can use Exists* property of Mouse to get the status.To find out network connectivity you can use IsAvilable* property of Network. You can further explore the power of My.

Before wrapping this off, I will tell you little about SQL Server 2005 Express. Right now there is no tool is out for this, one like Enerprise Manager to SQL Server 2000. I heard that you can connect to SQL Server 2005 Express using Quesry Analayzer of SQL Server 2000. If you really want to mangle with database using visual tool, then try to connect to database from VC# express or VB Express.

SQL Server in Action

Make sure before trying connecting to SQL Express, you start your SQL Express instance from your Computer Management Console. Run COMPMGMT.MSC and follow the nodes Service and Applications -> SQL Computer Management - > Services -> SQL Server. Then start your particular SQL Server instance. You will able to accomplish almost everything expected from SQL Serever.

Here I covered some new features those will come with VS 2005. I have not coverd any thing at the CLR level or language level. It sure that some of the things covered here may change, when final version of .Net Framework will ship. The fetaures covered here were to make you aware about forthcoming spices with .Net and to put you onto to gear with .Net Framework 2.0.

Note: Exists property of Mouse will not be available in next release of .Net 2.0 due to a bug reported by me. IsAvailable property of Network is also being diagnosed and I am doubtful about it existance in the next release of .Net.

No comments: