Professional Refactoring in Visual Basic

Book Cover

This is a somewhat unique book in that it is both on a specific subject and targeted at VB.NET. Quite a few books targeted at .NET these days are either introductory level, or target C#. Not to say that is bad, but it is refreshing to see VB.NET being targeted with a very focused book.

This book was published by Wrox in 2008, and is authored by Microsoft MVP Danijel Arsenovski. He maintains a website where he lists his book, and writes on programming topics, refactoring especially.

In starting out, the reader is instructed on the nature of refactoring, given a basic taste of the process, explained the various tools available to help the process, and introduced to the case study referred to throughout the book. The case study is called Rent-a-Wheels, an application that manages the status of a car rental fleet.

Following are a number of chapters that discuss various code smells in the case study application, and show examples of refactorings to resolve the issues. The smells are discussed in a light gray box, to set them apart from normal text, and are shortly followed by explanations of refactorings to resolve the smells. Along the way, the author discusses various quirks of VB.NET, and shows how the smells could have been established. This is all useful background material.

Aside from refactoring, the author also dedicates some space to unit testing, refactoring to patterns, and refactoring code from classic VB (e.g. VB6). There is also a chapter given to some new features in VB9, such as XML literals and LINQ. These new features have the potential to be quite useful, once I further update my various VB.NET projects to VB9 and .NET 3.5; I will be revisiting this chapter for certain.

The book finishes with a pair of appendixes, the first talking a bit about Refactor!, and the second providing some extra detail on the Rent-a-Wheels case study.

As a whole, the book goes through a decent number of code smells and refactorings. The coverage is not comprehensive, however the examples shown are clear and relevant. I believe the author did a good job of covering the more prevalent refactorings.

Generous code samples are shown throughout the book, but it may be easier to follow along if inspecting the code in Visual Studio. A code package for the book is available on the Wrox site.

To conclude, if you are working on a VB.NET project, legacy code in particular, that needs fixing up, this book is a worthwhile read to introduce you to refactoring and how to perform specific code transformations.