C# (RSS)

C#

Speaking at C# User Group of Greater Boston - 11/1

I'm late blogging about this, but I'll be speaking at the C# User Group of Greater Boston tomorrow night (November 1st).  The meeting starts at 6:30 at Microsoft's Waltham office.  Here is the session description:

Avoiding C# Traps and Pitfalls

As any developer knows, there's always more than one way to solve a coding problem. This is certainly true when using .NET and C#, but some approaches are better than others. For example, you probably know to use the Length property to check that a string is empty or that you should use StringBuilder when concatenating many strings. In this talk, we'll go beyond those basics to cover the "gotcha's" lurking in the shadows of C# and the .NET Framework. You'll see plenty of example code showing practices to avoid and your options for avoiding them. Every developer should know about these, but unfortunately, many find out after the fact. This is a good chance to learn from other developers' pains and immediately use these tips to make your applications better.

Hope to see you there!
-Chris

 

Code Camp IV - Just Around the Corner

Code Camp IV is just three days away now.  Unfortunately, if you haven't already registered, you won't be able to.  Response has been so strong that even the waitlist space has been filled.

However, for those of you who will be taking your weekend to come to CC IV, there is a very broad agenda of sessions available.  Thom Robbins has posted the traditional "Almost Agenda" (because change is always expected).

I always enjoy Code Camp and have signed up to give two presentations and a chalk talk, all on Sunday:

Presentation (Level 200) - Practical Software Development with Visual Studio Team System

This demonstration-heavy session, for software developers, answers the question "What's this Team System thing and how does it affect me?"  We'll begin with a very quick overview of Team System, then devote the bulk of time to walkthroughs of the features most relevant to software developers.  You'll see how integrated unit testing will make your code more reliable and maintainable, how static code analysis will help identify problems in your code and how profiling can identify performance bottlenecks - before your users do.  However, because the reality of software engineering is that developers are often called upon to conduct testing, we'll also cover the extensive web and load testing features of Team System.  Along the way, you'll see how Team Foundation works to integrate these activities, storing code, collecting data and generating reports.
 

Presentation (Level 200) - What's new in the .NET Framework 2.0?

November will see the release of the next version of the .NET Framework.  In this session, we'll focus on improvements made to the Base Class Library itself.  New classes and namespaces are available to make your job easier and many changes have been made to existing classes as well.  Support for 64-bit applications, compression, threading, DPAPI, FTP and many other improvements to networking and threading will be introduced.  You'll also see how new features and changes to System.Security improve support for developing secure applications.  Even our old friends System.IO.Console, System.GC and many base System types have new powers to inspire applause and tears of joy.
 

Chalk Talk (Level 300) - Effective Development Practices in .NET

Back for its third Code Camp, this interactive peer discussion focuses on development practices, from design to coding and deployment.  Specific topics are driven by participants but are always relevant to .NET development best practices.  Past talks have included Enterprise Library, successfully implementing development standards, code reviews, unit testing, SOA, practices sharing, performance analysis, class reuse, code management, useful tools, resources for training/education and more.  What’s worked for you and, equally important, what has not?  Having trouble implementing a specific practice in your organization?  Looking for tips on what tools might make your development life easier?  This session has been well-attended at previous Code Camps and is a great chance to pick the collective brains of other experienced .NET developers.

Hope to see you there!

-Chris

Using "using" to Alias Enumerations

Most people understand that the C# using directive allows creation of an alias as a shortcut to a particular namespace:

using MAE = Microsoft.ApplicationBlocks.ExceptionManagement;
...
MAE.ExceptionManger.Publish(exp);

Many people know that this can also be used to alias a particular class:

using EM = Microsoft.ApplicationBlocks.ExceptionMangagement.ExceptionManager;
...
EM.Publish(exp);

I had never thought to look any deeper than that until I saw how ugly our code was getting when consuming some long enumeration names which had been generated via a tool.  It turns out that using can create aliases to enumerations (and delegates or contained classes) of a class as well!

For example (ignoring the hideousness of the contrived example logic,) compare having:

public void AmazingFeature(ObnoxiouslyLongGeneratedEnumerationName mysteryFactor)
{
   
if ((mysteryFactor > ObnoxiouslyLongGeneratedEnumerationName.Second) && (mysteryFactor < ObnoxiouslyLongGeneratedEnumerationName.Fifth))
       
//...

Versus:

using OLGEN = Experiment.TestClass.ObnoxiouslyLongGeneratedEnumerationName;

public void AmazingFeature(OLGEN mysteryFactor)
{
   
if
((mysteryFactor > OLGEN.Second) && (mysteryFactor < OLGEN.Fifth))
       
//...

This should help us keep our lines of code shorter and easier to maintain.  I hope this helps you, too!

-Chris