01.Blogs :
travisowens  

Extending Intellisense

My XML Web Services class went great, I learned a lot.  But what I found amazing was that the guy next to me simply does not use Visual Studio's intellisense and he kept falling victum to spelling and case mistakes, talk about a waste of debugging time!

If you don't use VS's intellisense, then get use to it.  CTRL-SPACE is still my 2nd favorite feature of VS (my first is the design mode which builds code for me).

And on that note I'd like to point out a simple trick to extending Intellisense so that you can use it to auto-name your own code.

A good example is when you are calling Stored Procedures from your database. Even after you create your connection and dataset, you still cannot use Intellisense to get a list of the Stored Procedures you have available to your database (and we all know we're suspose to use Stored Procedures to retrieve and change data, and not pass SQL command stirngs, right everybody?)  The way around this is to create a new file in your project, let's call it globals.cs which would contain something like this...

using System;

{
  public class myStoredProcuderes
  {
    public static string SelectEmployeeByEmployeeID = "uspPlaypen_SelectEmployeeByEmployeeID";
    public static string SelectSomething = "uspPlaypen_SelectSomethingElse";
  }
}











Now from your main code you can simply type mySt and hit CTRS+SPACE and get  your class named and when you hit your classic . you get a list of your stored procedures via the names you have assigned.  This is good for three main reasons:
1... To prevent typos, any coder's worst habit
2... To give an more asthetically pleasing alias to your stored procedure
3... Because you ABSOLUTELY NEVER EVER want to hard code your app to something that exists outside the app.

Number 3 is important because it's possible you, or the DBA could change the name of the Stored Procedure and that would require you to change many lines of code.  Using this little globals.cs trick you would only have to change your code in one place.

PS: I still consider myself a .NET beginner, if there are any mistakes here or better methods, please let me know.

posted on Thursday, January 22, 2004 2:53 PM by travisowens


 
03.UPDATE CALENDAR :
<January 2004>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

05.MY LINKS :

07.Subscriptions :

Subscriptions


© Copyright 2005 Microsoft Corporation. All Rights Reserved.
Terms of Use | Privacy Statement | Code of Conduct | Hosted by MaximumASP for Microsoft
WHO-BAR