You are on page 1of 3

Top 10 .

NET Tips & Tricks

It's all about productivity lately. Otherwise we'd be all using Notepad to churn out
code. That's what this list is all about. You won't find here a faster algorithm to
search a binary tree. It's a list to get you ahead. With that in mind, I've compiled a
Top 10 list of tips, tricks and tools necessary to get you going fast. Most of all, the
list will help you stop wasting time on mundane dev tasks and have fun while at it.
This knowledge will propel you to the status of the "go to" guy (or gal), with an
appropriate raise in salary. Even though this is a top 10 list, the entries are in no
particular order.

10. Forget about debugging


So, you are debugging along through a library you've gone through a million times.
You know it works, it's solid. So stop wasting time going through it. Place a
[System.Diagnostics.DebuggerStepThrough()] for C# or
<System.Diagnostics.DebuggerStepThrough()> for VB.NET. This attribute tells Visual
Studio to skip the class while debugging through code.

9. Generate, generate, generate


I can't say it enough. But most people still won't get it. If you enjoy doing the same
task day in, day out, skip this entry. Anyway, 90% of applications do some type of
database access. For god's sake, generate the CRUDs, generate the stored procedure
wrappers, generate table-based classes. There is a myriad of tools out there to help
you in this department. Just do a google search on "vb.net code generator". For now,
let's do a 2 minute roundup. There is RapTier, but you need the expensive enterprise
edition for anything more than trivial. However, totally worth it. There is of course,
the king of generators: CodeSmith. It's great, so get it while it's free. There is the
free OlyMars of MSDN France code generator. Anyway, choice is not a problem.
Bottom line, you gotta generate.

8. Compare your databases


Here is one scenario. You are working in a team. You have your development
database. The DBA has his baseline database. You deploy your application and
something is not working. Something with the table or view or stored procedure or
who knows. So you look and look and finally you figure out that the problem is that a
table column has a different default on your copy of the database. At this point,
rather than wasting time figuring out what changed between your database and the
deployed database, just use a db compare tool. My tool of choice: SQL Effects Clarity.
It gives you a fantastic side-by-side view of both schemas and let's you drill down
into exact differences. Saves ton of time.

7. Refactoring/Productivity Plugins for Visual Studio .NET


After you've used a tool like ReSharper or CodeRush or the upcoming Refactor for
VB.NET, you'll wonder how you ever lived without it. True story, I used a trial version
of ReSharper for about a month, then it expired. I tried coding in the vanilla IDE and
I was appalled how bare it is in terms of helping the developer along. What are some
of the time saving features? For instance in ReSharper, if you reference a class for
which you forgot to enter a "using namespace" statement, it will figure out which
namespace matches and offer it to insert it for you. ReSharper also helps you
optimize your code. CodeRush, on the other hand, excels at knowing the context of
your code. of your code, and based on that, helps you reduce the amount of
keystrokes you type. For instance, you can type a common c# line
like using System.Windows.Forms; by typing: uswf. Get it? First letter of each word.
Very cool. And of course there are the rudimentary refactoring tricks.

6. NDoc Code Documentation Generator


This product falls into the category of completely and utterly impressing the living
hell out of your clients and bosses. "You mean you also write documentation? You
are just an uber-developer. I feel compelled to give you more money. I can't help it.
I can't help it." The app uses reflection to figure out what connects to what,
properties, methods, etc... and it uses XML comments that you should be writing on
top of every function. Right?

5. GhostDoc - your documentation sidekick.


Speaking of XML Comments, it's a chore. There just isn't any other way to look at it.
Enter Roland Weigelt's GhostDoc. You right-click on the function, select 'Document
This' and IT DOES IT. Yes, based on the name of your function, GhostDoc figures out
it's intent!!! Well, most of the time. The rest go into the GhostDoc hall of shame. So, if
you are lazy and leave your form name at Form1, your Form1_Load event will be
documented as "Form1_s the load." However, once you get grok how the tool works
(which took me a grand total of 2 minutes), and name your functions accordingly,
you can forget about ever documenting your code.

4. See both the Form and Code views.


VS.NET offers Vertical and Horizontal Splits in the Windows menu. This allows you to
setup your environment so that you see the Form and the code for it at the same
time. Another variation on the theme is dual monitors. If you have dual monitors,
you could use a utility such as UltraMon to extend your IDE across both monitors,
setup a vertical split and voila - writing code in style.

3. DotNetRocks
Your drive to work/contract is about 30-60 minutes. And you already have an MP3
player of some type. So let's connect the dots here, as they say in the post 9/11
world. Head to your favorite electronics shop (such as Radio Shack in US) and get a
tape adapter (or similar device). Then connect the MP3 player to the tape adapter
and you are set. Now download a couple of episodes of DotNetRocks. These guys are
funny, knowlegible, have great and well-known guests on weekly. And up to a couple
of weeks ago (when Rory was still there), their raunchyness could only be matched
by the likes of Howard Stern.

2. Visual Studio 2005


Ok, so it is not out yet. However, even coding in the betas makes the current
generation of tools feel like Notepad. The improvements are very substantial - it has
a bit of VB6 satisfying feels. Among the goodness in this release are debug
visualizers (this is gonna be huge), better intellisense for c# (about time), Edit &
Continue and a host of others. Should kick the productivity a notch or two. I realize
that most of the time the choice of tools is not up to the developer, but the
employer. Regardless, if you can, opt for VS2005.

1. And the #1 tip is the vast array of resources that are at your disposal.
For whatever reason, many, if not most, programmers hardly ever use any of the
available resources to help themselves out. Here is the multitude of resources I use
in no particular order:

• Google - that's self-explanatory


• Google Groups - they recently changed the interface for the worse, which made
it a lot more difficult to find what you need, but it still does the trick
• If you have a question where do you go? Microsoft-run newsgroups are still
arguably the best place to ask questions. Then, of course, our own forum.
Various mailing lists are also pretty good, but the amount of email traffic
required to ask a single question is daunting. Here is one.
• Blogs. Now that many high-end developers both at Microsoft and other places
are blogging, you are likely to pick up tidbits of info there as well. vbRad.com
has conviniently sorted the blogs by their update time, so you always see the
latest and greatest. There are other places that have aggregated blogs for
you as well, such as MSDN, but those places are usually limited to company
employees.

You might also like