Category Archives: Agile

Jeremy has organized his best posts in the last three years. Please check it out frm there. I think I have learned a lot from Jeremy’s postes. Great stuff include MVP pattern, TDD (Test-Driven Development), Mock Object, Depencency Injection, and so on. Every single post from his is worth reading. By the way, just happen to know he is goint to write a book. It must be a MUST READ.

I just came across a blog from Fredrik Normén talking about Dependency Injection and Mock object. I have been using those a lot in my recent projects. Fredrik’s blog gives me a very intertesting idea how to organize and test my application. Currently I seperates the test project from the production project. After I tested my DAL and BLL, then integrate them together into main project. Now I am thinking about to Mock BLL and DAL and inject them into web/Wind project, so that I can test the whole application without touching database.

One of the great technical books which inspired me a lot is Rod Johnson’s “Expert One-On-One J2EE Design and Development”. In this book, Rod laid out couple very important application design principles. Two of them are:

  • OO design is more important than any implementation technology.
  • Testability is essential.

Those principles are not only for J2EE development, but also can be applied for most any application development regardless platforms. I found too many .Net developers ignore those valuable guidelines. You probably can see “spinetti” code almost everywhere. Data access logic is tangled in ASP codebehind, or business logic layers are mixed with data access codes. I think probably one of the reasons is coding habits inherited from VB, which very easy leads to procedure code. And Microsoft’s strong encourage to use stored procedure for “improving performance” is probably another one. Writing software is really a maintenance job. In my poin to of view, maintainability is most important factor in development process. Don’t getl me wrong, I still think performance, scability and any other abilities are very important. But maintainability is more critical. It will help improve developers’ productivity by reusing the code base, easy to change funtions to meet the business requirements. It at best improves ROI. I will save OO and architecture design in later, and only talk about some of testing framework which can help .NET developers improve testabilities in their code.

Before you go even further, I have to recommend you to read a excellent article by Justin Gehtland, “10 ways to make your code more testable“. To write readable code is a skill. It cannot easily be achieved by any testing tools, even the new version of Visual Studio .NET. It has learning curve, it requires developers to apply OO principles and patterns in the application design and development. I will discuss TDD and how OO can help to do TDD in another post.

Here are some of the unit testing framework I found and using currently, and they approve great benefits for my development. From my personal usage experice, I categories to three types to corresponding to three tiers development enviroment.

- Data Access Layer

Basically DAL is responsible for Create/Retrieve/Update/Delete (CRUD). There have some arguments that if the unit test should touch database. My option is clear, we should. One of the practice is to restore the database every time before unit testing. It is easy to be done by NAnt. There have couple materials showing how to do that.

1. CodeProject Continuous Database Integration

2. 15 Seconds Automated Backup wiht NAnt

3. Thycotic Software .NET TDD Starter

NUnit testing is the classic and very common one. I used it in my TDD early age, until I find MbUnit coming with TestDriven.NET. MbUnit actually extends the basic function of NUnit and add a lot nice features, for example RowTest which can take testing data row by row as the parameters, or RollBack feature which can do database roll back with COM+ 1.5. Rollback is a great feature to clean the testing data after unit testing. Another thing I like to mention is make sure to download TestDriven.NET. It is a such nice testing framework integreated with NUnit, MbUnit, and visusal studio .net 2005 testing framework. Besides that, it has integrated with NCover and NCoverExplorer. I cannot explain how nice and how much helpful those tools are. It shows very clear my unit testing coverage by highlighting the source code. It also can generate html reports to show the result.

In the next part, I will discuss business component testing and UI testing. Stay tone :=)