This Blog is the first in a series of Blogs that I intend to write about new concepts and ideas that I discover in my travels through .NET. These will not neccessarily be my ideas - in fact most of them won't be, but I hope you will find them interesting and useful for your own development projects.
A few weeks ago when the new codeplex-based DNN Forge was introduced, I created a project that I called "The Family Tree project". I have been working off-and-on for about 3 years on both a GEDCOM parser and a rich Object Model for managing Family Tree information. The problem I had with this project is that early on I had taken a Waterfall approach to the design, and as this was a hobby project - and therefore I had limited time to work on it - the progress was painfully slow.
On Friday, after returning from the MVP summit and seeing all the cool new stuff coming along as well as a new emphasis on Test Driven Development, I decided to take a new approach to this project.
I decided to start anew - using an Agile development process. Why an Agile process? My previous efforts resulted in poor progress as the tasks seemed so large to complete, and so I always found excuses to do something more interesting. Using an Agile process I can work on a single feature (eg List all Individuals) and get that feature working at all levels, before moving on to the next feature.
Andrew had recently downloaded Rob Conery's videos where he uses a TDD approach to rewiting the Commerce Starter Kit using MVC. So we decided to try using TDD (Test Driven Development) ourselves on this project. As I expect the project to take some time to complete, we also deccided to build it in ASP.NET 3.5 using the latest bits.
On Saturday, Andrew and I spent most of the day "Pair-Programming" the first "feature" - List Individuals. In about 6 hrs we were able to complete all the tests to test all layers of the application, from the View down to the database for this single feature.
So even before we actually browsed to the page we were pretty confident that everything would work - and it did. Next we added the tests for "View" a single Individual. As we had built much of the framework and hooks between the layers, this took less than an hour to complete, and again once we knew all the tests worked we were quite confident that browsing to the site would work and it did. These two features, which are essentially feature complete (although all we are returniing is a first name and last name for each individual) resulted in 28 tests. It really is cool to see all those green lights each time you make a change.
Although, you might think that TDD is more time-consuming as you have to write a whole bunch of test code - I think these results demonstrate that you can be productive - as you can be confident - if each test continues to pass - that new work does not break what you have already completed.
It is hard to convert an existing project like DNN to Test Driven Development - but I would urge you to consider this approach when starting new projects.
In future Blogs in this series I will share with you my "Gleanings" as we work through the project. Below is a list of some of the decisions we have made about what we will use for this project, but as we are being Agile this is just a first stab.
- Use a TDD development approach to test ALL Layers of the Application.
- Use MoQ as a Mocking Framework to help in the testing - we will also use a Web testing framework like WATIN or WebAii, so we can automate tests on the "browser" part of the equation.
- Use an IoC (Inversion of Control) Container
- Use all the new syntax sugar in C# 3.0 like Extension methods, Lambda Expressions, LINQ - sorry, I do all my non-dnn development in C# so I can keep up to date in both languages.
- Use LINQ in the Data Layer (LINQ to SQL for now - but we may switch to LINQ to NHibernate or LINQ to Entities)
- Build an MVC-based Website front end - Initially this part of the project is mainly designed as a learning experience, but this may become a full-blown application
- Create an MVP (Module View Presenter) style Module for DNN (see Phil's blogs on this approach to Module Development)
- Expose a Web Services Interface for Silverlight (RIA) and WPF (Windows) clients