Skip to content

Learning and Staying Current in .NET Development, Part 2

Here are more ways to build and supplement your programming knowledge.

Stack Overflow is a free programming question and answer site.  Search the existing database or ask and answer questions to build reputation points.  Lots of talented developers commit their brainpower to making the stackoverflow community great, so it’s worth checking out.

Personal projects

Always have a personal project that you enjoy working on, and make sure to write code every day, even when your job doesn’t require it.  If you don’t like programming enough to do it outside of work, you may want to reconsider if software development is right for you.

Open source projects

Contributing to open source projects helps you demonstrate your abilities to prospective employers because it makes your work easily accessible.  It also shows that you’re self-motivated and committed to your own education. is currently the largest open source development Web site, while CodePlex is hosted by Microsoft, and indexes Unix and cross-platform software.


Read developer blogs to see what others in the industry are up to.  NOOP.NL maintains a list of the top 200 blogs for developers.  That should keep you busy for a while.

Developers on Twitter

What goes on in the minds of other programmers?  What are their daily routines like, and what do they choose to share with the world?  Much like the list of top blogs, NOOP.NL maintains a list of top developers to follow on Twitter.

Your own blog

Writing your own technical blog can make you a better developer and help you earn the respect of your peers.  Why?  Because making a good programming blog is hard.  In order to write authoritatively on any subject, you should know that subject inside and out.  Just coming up with blogging topics can be a challenge.  If you’re having trouble, read the advice of other technical bloggers.

Tweet about programming

Rather than just read about other people’s lives, open a Twitter account and try to write something programming-related every day.  It will force you to read the news and think about what’s interesting.  If you don’t want to bore your followers, that is.

Programming competitions

Programming contests help you hone your skills by pitting yourself against other developers.  It’s fun to win, but just participating can help you gauge and improve your abilities.  Check out Google Directory for all kinds of challenges.  TopCoder is one place where the competitions are going on all the time.

User groups

User group meetings are a good place to go for networking.  They can also be an opportunity to practice your public speaking skills.  Teaching others is one of the most effective ways to learn.

Magazines and journals

Magazines like MSDN Magazine and Visual Studio Magazine release monthly issues available in “dead tree format” and online.  You may be able to get subscriptions for free if you’re an industry professional.


Although this is a controversial topic, I do see at least some value in studying for and taking certification exams.  Doing so helps you round out your knowledge, and if nothing else it gives structure to your learning and a goal to accomplish.
Whatever you do, don’t delude yourself into thinking that certifications are all you need.  At best they are a supplement to the coding and reading you should already be doing.

Social news sites

“Social” news sites are news sites with a reader-participation element, such as voting on articles.  Digg, Reddit, and Slashdot fall into this category.  While some of the material appearing on these sites is legitimate tech news, there is often a lot of noise to filter through.  It’s up to you whether it’s worth it.

And finally, the #1 most important resource for developers

When in doubt, Google.  The search engine is such an essential tool that we often take it for granted.  There’s even a site, “let me google that for you“, that pokes fun at those who refuse to perform their own searches.  Don’t underestimate the value of good search skills.  Nobody knows everything, but finding new information efficiently is fundamental to job performance.  Take a look at Google’s search tips if you haven’t already.


Learning and Staying Current in .NET Development, Part 1

This series lists some of the resources I use to educate myself and stay informed about new technologies.  Take a look if you’re a fledgling developer just starting out, or if you’re simply looking for a new way to keep up-to-date.

These are mainly aimed at the Microsoft development stack, but many are transferable to other platforms.

Microsoft resources

MSDN Flash Developer Newsletter

You can subscribe to MSDN Flash if you want to get news delivered directly to your inbox, or you can just go to the Web site and view the latest issue in your browser.

MSDN Events and Webcasts

Check to see if Microsoft has any in-person events near you.  The presentations are informative and you’ll get the opportunity to network with other local developers.  Sometimes they even give out free stuff like books or software licenses.

The event portal also links to various Webcasts in case there aren’t any live events in your region.

Channel 9

Channel 9 is a community for learning, and a place to get videos, podcasts, and screencasts. You can also watch shows and participate in the forums. There is a ton of content here, and there’s always something new.


If you’re a student, DreamSpark will get you free access to all sorts of developer tools that would otherwise be prohibitively expensive.  Visual Studio, SQL Server, and Expression Studio are just some of the products offered.

Beta software

Don’t underestimate the value of downloading software while it’s still in beta.  Visual Studio in particular is known for it’s very high-quality pre-release versions.  A good way to guarantee you don’t fall behind is to become an early adopter.


Even in an increasingly online world, books are ideal for assimilating large amounts of information at once.  Do yourself a favor: take a break from clicking and start flipping pages for a while instead.

The Pragmatic Bookshelf

Pragmatic books are concise, well-written, and authored by people who are clearly passionate about the subject matter.


O’Reilly has historically published some of the best technology books available, although their consistency has declined somewhat in recent years.


The Mythical Man-Month

Provides several insightful essays like “The Mythical Man-Month”, “The Second-System Effect”, and “No Silver Bullet”.  A must-read, even if it is showing its age in some parts.

Design Patterns: Elements of Reusable Object-Oriented Software

Also known as the “Gang of Four” (GoF) book, Design Patterns is full of elegant solutions to commonly occurring problems in software design.

Other books I’ve read and recommend

C# in Depth: What you need to master C# 2 and 3 by Jon Skeet
This is for serious C# developers who already have a background in the language.  Skeet’s thorough coverage, attention to detail and precise wording make this an awesome learning tool and reference.  The second edition is due out in August.

The Passionate Programmer: Creating a Remarkable Career in Software Development by Chad Fowler

More inspirational than technical, this book offers numerous tips for becoming a great developer.

Coders at Work by Peter Seibel
Peter Seibel interviews 15 notable programmers.  I’m only a few chapters into this one so far, but it’s fascinating to probe the minds of those who have been so influential in our industry.

Joel on Software: And on Diverse and Occasionally Related Matters That Will Prove of Interest to Software Developers, Designers, and Managers, and to Those Who, Whether by Good Fortune or Ill Luck, Work with Them in Some Capacity by Joel Spolsky

Joel is known in part for his widely read blog posts, several of which have been bound together here in book form.  And yes, that really is the subtitle.

Hackers and Painters: Big Ideas from the Computer Age by Paul Graham

It’s interesting to note Graham’s support for Lisp, and the increased adoption of Lisp-like features into new languages since this was written.

The Cathedral and the Bazaar: Musings on Linux and Open Source by an Accidental Revolutionary by Eric S. Raymond

If you struggle to find anything new while reading this book, it’s only because it’s been such an enormous influence over the past decade.

Just for Fun: The Story of an Accidental Revolutionary by Linus Torvalds

Any developer who remembers tinkering with code at a very young age will relate with nostalgia to Torvalds’ geekiness.  This story is indeed fun.

Hackers: Heroes of the Computer Revolution by Steven Levy

Ever wonder how hacking began?  Real, true hacking that started around the 1950’s?  Hackers offers a peek inside the world of those who lived it.

Gödel, Escher, Bach: An Eternal Golden Braid by Douglas R. Hofstadter

This is not a programming book, but a clever, philosophical work of art.  It’s not for everyone, but if you have a curious and analytical mind you might enjoy it.

Facebook’s New, Simplified Privacy Settings

Facebook's new privacy settings

My Attempt at Humor

Worker productivity chart

How to Create a Pinned Cygwin Icon in Windows 7

Pinned Cygwin icon

When you install Cygwin, it creates a shortcut to the Cygwin.bat file that resides in the installation directory.  But if you try to pin it to the Windows 7 taskbar with drag-and-drop, it won’t work.  Here’s how you can do it:

  1. Right-click on the desktop, and in the context menu, select New->Shortcut.
  2. In the dialog box, enter the location of the shortcut item.  If Windows and Cygwin are installed in the default locations, it will be something like:
  3. C:\Windows\System32\cmd.exe /c C:\cygwin\Cygwin.bat

  4. Click “Next”.  Enter “Cygwin” for the shortcut name.  An icon with the C:\ command prompt will appear on your desktop.
  5. Right-click the icon and view Properties.  Click the “Change Icon…” button.  Browse to the Cygwin installation directory and select Cygwin.ico.
  6. Double-click the new desktop shortcut and make sure the Bash shell appears.  Right-click the icon in the taskbar and select and select “Pin this program to the taskbar”.  You’re done!

Alternatively, you could just run cmd.exe, pin it to the taskbar, and edit the properties to run Cygwin.bat while it’s pinned.  But then you would not be able to alter the icon as easily.

Facebook’s Official PHP Client Library Moves to New Location, now PHP SDK

Joyent, a Web hosting company, is offering free Facebook app hosting for one year.  So far my experience with it has been pleasant, but I’m not sure how I’d be faring without plenty of prior experience building Web apps.

Joyent supports Ruby on Rails, PHP, and Python for Facebook development.  I decided to follow the path of least resistance and go with PHP, since they support it “Out of the Box”.  I got a “Hello World” app running out the gate quickly, but when I tried to install the Facebook Client library, I ran into trouble.

The developer wiki on Joyent’s site wants you to go to a Subversion repository on Facebook, but the link is dead so their instructions fail.  Facebook’s dev Wiki, on the other hand, links to GitHub.

To make it work, I logged into my Joyent account via SSH and ran these commands:

cd ~/web
mkdir php
cd php
curl 2>/dev/null |\
gtar -xzf - --strip-components=2 'facebook-php-sdk-94fcb13/src/facebook.php'

(I got the URL for the gzip file by navigating to, clicking the most recent tgz link, and noting the download location in the Firefox download dialog.  I’m sure there are easier ways to do this.)

Then you’ll get a php directory with the facebook.php file, and you can include it in a script in your public directory like this:

require '../php/facebook.php'; ?>

Note:  I just took a peek at Facebook’s wiki history and I can see that they updated this on April 29th (3 days ago).  Also, it looks like the name has changed from “Facebook Client library” to “Facebook PHP SDK”.

Visual Studio 2010 Helps You Grok Other People’s Code Quickly

Have you recently started a new job or project where you need to get up to speed on an existing code base rapidly?  Earlier versions of Visual Studio added features like the Class Designer.  Now, VS 2010 provides several more tools to assist you.

View Call Hierarchy

“Find All References” not cutting it? Somewhat like a design-time call stack, the call hierarchy helps you visualize program flow much more easily.

View Call Hierarchy

View Call Hierarchy

A bit of trivia: View Call Hierarchy will only let you drill down into a recursive call once before showing the message “Further expansion is not supported for recursive calls”.

Sequence Diagrams

Here’s another context menu item that you can get by right-clicking on a method. You can reverse engineer your code to get an automatically generated sequence diagram.

Sequence Diagram

Sequence Diagram

Incidentally, this screenshot also shows another cool feature of VS 2010: detachable tabs. You can even detach code tabs.

Reading code that you didn’t write (or wrote a long time ago and forgot how it works) is one of the biggest challenges facing developers. It’s nice to see Microsoft building a solution to this problem into its flagship development tool.

Using Web.config Transformation in Web Site Projects

A Brief History of Web Site Projects

With the release of Visual Studio 2005, the ASP.NET Web Application was replaced with something called a “Web Site Project”.  There was a strong backlash in the development community, and Microsoft gradually reintroduced the Web Application template to their suite of development tools.

That might have been the end of Web Sites, but Microsoft decided to keep them and the Web Site option is still available in Visual Studio 2010.

A Web.config for Every Environment

If you’ve worked on many ASP.NET projects, you’ve probably seen Web.configs that look like this:

    <add name="DevelopmentDatabase" connectionString="Data Source=devServerAddress;Initial Catalog=devDataBase;Integrated Security=SSPI;"/>
    <add name="TestDatabase" connectionString="Data Source=testServerAddress;Initial Catalog=testDataBase;Integrated Security=SSPI;"/>
    <add name="ProductionDatabase" connectionString="Data Source=prodServerAddress;Initial Catalog=prodDataBase;Integrated Security=SSPI;"/>

You uncomment the relevant settings for the current environment and comment out all the rest.

Alternatively, you could have separate Web.configs for each environment and keep them in sync manually.  Or maybe you’ve created build events to manipulate or copy the right Web.config to your output directory based on project configuration.  But that doesn’t work in a Web Site project for one simple reason – Web Sites don’t have project files, which is where the configurations are stored.

None of these solutions is as good as the one that Visual Studio 2010 now offers: Web.config Transformation.  When combined with the new Web Package functionality, this provides an easy, automated way of generating Web.configs with environment-specific settings, without duplicating the shared settings.  This makes maintenance easier and reduces the risk of human error.

There are already good resources out there for using Web.config Transformation so we won’t go into depth demonstrating them here.

No MSBuild, No Transformation

The normal way to transform your Web.configs is to create a package, but it can also be done by running MSBuild at the command line with a target of TransformWebConfig:

msbuild MyProject.csproj /t:TransformWebConfig /p:Configuration=Debug

However, neither of these options are available from a Web Site.  The Add Config Transforms and Create Package menu commands are missing, and without a .csproj file, the MSBuild method won’t work.

Hacking a Project File So MSBuild Will Do Our Bidding

These limitations may discourage you from using Web Site projects altogether.  But with a little persistence we can work around the issues.

We need MSBuild to transform our Web.configs, and we need a project file for MSBuild to work.  To solve this, I created an empty ASP.NET Web Application and made a copy of the project file that was generated. Then I opened it in a text editor and distilled it down to the minimum content necessary for our purposes:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="">
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <Content Include="WebSite1\Web.config" />
        <Content Include="WebSite1\Web.Debug.config">
        <Content Include="WebSite1\Web.Release.config">
        <Compile Include="Dummy.cs" />
    MSBuildBinPath)\Microsoft.CSharp.targets" />
    <ImportProject="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

Lines 9-14 contain PropertyGroups with the project configurations you want to define.  There is a one-to-one correspondence between the project configurations and the Web.config transforms.  For example, if you specify Debug and Release configurations, you should specify Debug and Release transforms as well.

Lines 15-23 contain an ItemGroup with your Web.config and its transforms.

You’ll notice that the files are all in the WebSite1 directory, which is the main directory of the Web Site.  The project file gets saved one directory level up, for reasons I’ll explain later.

The problem with MSBuild is that it wants to, well, build something.  We don’t care about normal project output like an executable file or library; that goes against the concept of using a Web Site project in the first place.  All we need are the transformed Web.config files.  But if we don’t feed MSBuild at least one source file, it will throw an error:

CSC : fatal error CS2008: No inputs specified

Fortunately there’s no rule saying that the source file can’t be empty.  Line 25 gives the name of a dummy file that we provide to MSBuild so it doesn’t complain.  The file is zero-length.

Once you’re done setting up your project file, save it with an extension other than .csproj.  This isn’t a “normal” project file, and you don’t want Visual Studio messing with it.  I chose the file name

Finally, you’ll want a way to run MSBuild easily without having to fire up the Visual Studio Command Prompt every time.  For now we can create a batch file named build.bat with the following commands (msbuild may be located elsewhere on your machine):

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30128\msbuild /t:TransformWebConfig /p:Configuration=Debug

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30128\msbuild /t:TransformWebConfig /p:Configuration=Release


Putting Things in the Right Place

The aim of this process is to add the benefit of Web.config Transformation while maintaining the simplicity of a Web Site project, so you don’t want to clutter your site with project files, dummy source code files and batch files.  For this reason, the files used in the transformation process (except for the transforms themselves) will be stored one directory level above your Web Site’s main directory.  That way you can still do an XCOPY deployment with minimal effort.

Here’s an example of the folder structure:

Folder structure

WebSite is the highest-level directory, and it has the following contents:

Folder contents

WebSite1 is the name of the main Web Site project directory; yours will probably be different.  Dummy.cs is the zero-length dummy file MSBuild needs to run without failure.  build.bat and are the batch file and modified project file we created in earlier steps, respectively.  The bin and obj folders are generated when you run the batch file that performs the build.  bin can simply be discarded or ignored.  obj will contain the original and transformed Web.configs.

Building is easy: simply double-click the batch file to run it and you should get a “Build succeeded.” message.  Then, when you’re ready to deploy your site, simply copy the transformed Web.config from the appropriate folder under obj.

If you have a compelling reason to use Web Sites instead of the Web Application template and you don’t like manually tweaking Web.configs all day, then hopefully this technique will be of some value to you.

Getting Code Contracts to Work in Visual Studio 2010 RC

Microsoft released Visual Studio 2010 RC to the public on Wednesday along with .NET Framework 4.  One of the new framework features is Code Contracts.

Contracts, like assertions, express assumptions in your code by testing conditions.  For example, the following code requires someParameter to have a value greater than zero or a failure message is displayed:

using System;
using System.Diagnostics.Contracts;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)

        static void DoSomething(int someParameter)
            Contract.Requires(someParameter > 0, "someParameter must be greater than zero.");

Code Contracts surpass assertions with their ability to do static checking.  They can detect contract violations during a build without even running your code.  They’re also tailored for specifying method-boundary contracts (preconditions and postconditions) while assertions are not.

I assumed contracts would work out of the box, but unfortunately that’s not the case.  .NET 4 does include the System.Diagnostics.Contracts namespace and allows you to write contract-based code, but it won’t do anything unless you install Code Contracts separately.

Download Code Contracts from Microsoft DevLabs

After the install you’ll see a new tab in your project properties called “Code Contracts”.  There you can specify Runtime Checking, Static Checking or both.

Enabling contract checking

Enabling contract checking

Note that static checking is only available in the Premium Edition, which will only install if you have VS 2010 Premium or Ultimate.  The barrier to entry here is too high, in my opinion.  Have a look now before the release candidate expires and these features are out of reach to the average developer.