How CAB and TDD helps doing better designs
August 11, 2006
The last months I’ve been working on an exciting project using VSTO, Excel and Team Foundation Server. We discussed with Matias how we should design this application. In this kind of projects, a great deal happens in the spreadsheet, and the business logic behind, is big as well. If you did VBA programming you know what I’m talking about.
We needed a clean and extensible design. So we decided to use the Composite UI Application Block and the Smart Client Software Factory, because:
- It provided us with a Dependency Injection container (ObjectBuilder)
- Leverage the MVP pattern which is very TDD-friendly
- Separate functionality in different modules
We realized that the key for being successful was the orchestration between the spreadsheet and the services. This is where TDD proved to be the correct path because allowed us to design this orchestration in a clean way.
The following illustration put it more clear.
- The View is the spreadsheet
- The Presenter performs the business logic and he knows about its view and services by their interfaces
- The Services communicate with Team Foundation Server to retrieve workitems.
The following picture describes our solution
In the retrospective after finishing this project, we realized two things:
- TDD was extremely useful to come up with a clean design that provided loosely coupling between the components
- In the final stages of the project, we met with a lot of technical details regarding VSTO and Excel and it was hard to keep the unit tests up to date. This is something that we are looking to improve in the following projects
[TestMethod]
public void CheckValidationAdded()
{
presenter.PopulateLists();
Assert.IsTrue(view.FeatureValidated);
Assert.IsTrue(view.OwnerValidated);
Assert.IsTrue(view.ItemOrGroupValidated);
}
In the example above we tested that when the PopulateList method is called the Presenter behaves properly that means to call AddFeatureValidation, AddOwnerValidation and AddItemOrGroupValidation methods. UPDATE: To take a deep dive in this check my recent post about How-To write MVP using TDD
Leave a Reply