Top 10 .NET Tips & Tricks

Embed Size (px)

Citation preview

  • 8/7/2019 Top 10 .NET Tips & Tricks

    1/3

    Top 10 .NET Tips & Tricks

    It's all about productivity lately. Otherwise we'd be all using Notepad to churn outcode. 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 aTop 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 noparticular 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 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 ofdatabase 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 helpyou 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 enterpriseedition 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 thefree OlyMars of MSDN France code generator. Anyway, choice is not a problem.

    Bottom line, you gotta generate.

    8. Compare your databasesHere 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 orwho 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 thedeployed 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 downinto 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 forVB.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 andI 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 forwhich you forgot to enter a "using namespace" statement, it will figure out which

    http://www.sharppower.com/http://www.ericjsmith.net/codesmith/http://www.microsoft.com/france/msdn/technologies/outils/olymars/default.asp?lang=enhttp://www.sqleffects.com/http://www.jetbrains.com/resharper/http://www.devexpress.com/products/NET/Coderush/http://www.devexpress.com/products/NET/Coderush/http://www.sqleffects.com/http://www.ericjsmith.net/codesmith/http://www.sharppower.com/http://www.ericjsmith.net/codesmith/http://www.microsoft.com/france/msdn/technologies/outils/olymars/default.asp?lang=enhttp://www.sqleffects.com/http://www.jetbrains.com/resharper/http://www.devexpress.com/products/NET/Coderush/
  • 8/7/2019 Top 10 .NET Tips & Tricks

    2/3

    namespace matches and offer it to insert it for you. ReSharper also helps youoptimize 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 ofkeystrokes 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 livinghell 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 ontop 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 outit'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 bedocumented 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. DotNetRocksYour 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/11world. 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 adapterand you are set. Now download a couple of episodes ofDotNetRocks. 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 matchedby the likes of Howard Stern.

    2. Visual Studio 2005Ok, 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 hasa 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 &

    http://www.roland-weigelt.de/ghostdoc/hallOfShame.htmhttp://www.dotnetrocks.com/http://www.microsoft.com/http://www.dotnetrocks.com/http://www.keyhole.com/http://www.roland-weigelt.de/ghostdoc/http://ndoc.sourceforge.net/http://www.roland-weigelt.de/ghostdoc/hallOfShame.htmhttp://www.dotnetrocks.com/
  • 8/7/2019 Top 10 .NET Tips & Tricks

    3/3

    Continue and a host of others. Should kick the productivity a notch or two. I realizethat 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 usein 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 stillarguably the best place to ask questions. Then, of course, our own forum.

    Various mailing lists are also pretty good, but the amount of email trafficrequired 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.comhas 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 companyemployees.

    http://www.google.com/http://www.google.com/http://groups.google.com/http://groups.google.com/http://www.vbrad.com/discuss2/exec.asp?cmd=GroupView&GroupID=7http://peach.ease.lsoft.com/archives/visbas-l.htmlhttp://www.vbrad.com/blogs/dotnet.asphttp://www.vbrad.com/blogs/dotnet.asphttp://www.vbrad.com/blogs/dotnet.asphttp://www.google.com/http://groups.google.com/http://www.vbrad.com/discuss2/exec.asp?cmd=GroupView&GroupID=7http://peach.ease.lsoft.com/archives/visbas-l.htmlhttp://www.vbrad.com/blogs/dotnet.asphttp://www.vbrad.com/blogs/dotnet.asp