i-think Twenty-Two

Now with more coherency.

Visual Studio, .NET and Developer Productivity

| Comments

Recently I’ve had to work on porting a .NET app to Ruby. The .NET version consumed WCF web services, exposed WCF web services, parsed XML and relied on multiple threads. The experience reminded me of one thing: the awesomeness of .NET and Visual Studio.

.NET’s documentation is pervasive

.NET seems to have been designed from the start to encourage excellent documentation. With XML documentation all the important parts of a method and a class are able to be encapsulated. Using a tool like GhostDoc (which is free) a skeleton for the documentation can be written for you.

In Visual Studio as you code you are constantly presented with relevant documentation as you code. If you need more help you can press F1 to be taken to the relevant page from the MSDN library.

The .NET Framework is generally well laid out

I’m sure someone can come up with an exception, but generally the .NET framework is well laid out. IO functions can be found in System.IO, Windows form controls sit in System.Windows.Forms. Knowing where to look for things goes a long way to improving the discovery of methods and types leading to a less steep learning curve.

It also serves well for discussions. If you want to working with XML you can be told to check the classes in System.Xml. Want to check out the new LINQ to XML classes, they are sitting in System.Xml.Linq, right under the System.Xml namespace.

The .NET Framework has consistent naming

Classes and method names have consistent case rules that make it easy to work in a case-sensitive environment. Consistent use of prefixes (like ‘I’ for Interface) and suffixes (like ‘Exception’ for exceptions) helps developers identify the purpose of a class without looking deeper. Fortunately Visual Studio makes looking deeper easy. Design guidelines for developing class libraries encourage developers to stick with this consistent approach. Furthermore, tools like StyleCop and FxCop can help make sure your code is consistent.

Even the basic documentation is good

The class documentation on MSDN is generally excellent, but even at its core, just listing the members, constructor overloads and object hierarchy goes a long way to understanding a complex framework. It is well organised (using the namespaces we’ve already discussed) and easy to navigate.

Working with Ruby’s documentation really made this apparent. Whilst the ruby docs can have this information I have seen members not listed in documentation, and the three top panes are almost impossible to navigate (from left to right, a list of source files, a list of all classes and modules, and then a list of all members). These lists get so long that it is difficult to scroll to the right spot and even then it can be hard to pick the item you want.

Visual Studio makes it easy to navigate your code

Enterprise applications are large, so being able to navigate through your own code needs to be as quick and easy as possible. In Visual Studio it is easy to navigate to the declaration of a type or a method. In addition to Visual Studio’s navigation features I also make use of ReSharper (not free, but so worth it) to navigate to a member, a particular file, references, etc. This ease of navigation improves my productivity greatly.

Did I mention how much I love IntelliSense?

Seriously, IntelliSense is the greatest IDE feature ever. It improves the discoverability of classes and methods and reduces errors in code. ReSharper has a handy feature which let’s me take advantage of camel casing too. I can type ‘ArgN’ and still be presented with the option of an ArgumentNullException. This has saved me a lot of time I would normally spend using the dreaded cursor keys to select the type I want.

Simple refactoring made easy

Changing the name of a method or type in Visual Studio is simple. References can be updated to reflect the change. Making a change like this by hand is time consuming and prone to error. Again, tools like ReSharper can take this further.

The joy of compilation

Compilers are awesome. Not only do they now do a lot of type inference magic, but they can help identify many of the common little problems that arise in code such as minor typos, invalid syntax and undeclared variables. The C# compiler generally returns good error messages that help identify problems quickly. Some of the errors I saw while running my Ruby port were reasonable and certainly allowed me to solve the problem, but often I would need to go deep into the code before these problems become evident. I needed to make thorough use of unit tests just to be confident that the code was syntactically valid.

Too much hand holding?

My experience with Ruby has certainly highlighted my reliance on tools like Visual Studio to help me write my code. At the same time I recognised that I was making fewer errors over time writing all my code in a text editor. Perhaps it is beneficial to code in a text editor from time to time, but for anything with more than a few methods or classes you won’t see me giving up Visual Studio (and ReSharper) any time soon.

Comments