Showing posts with label TDD. Show all posts
Showing posts with label TDD. Show all posts

Tuesday, July 1, 2008

Upgrading to NANT 0.86 for .NET 3.5

Recently, having to upgrade the project I am working on from .NET 3.0 to 3.5, I did not realize that the NANT 0.85 is unable to support the building of .NET 3.5 project till I tried to build the project. In order to continue to automate the build process of the project, NANT 0.86 beta 1 have to be used. During the upgrade I have hit some problem and will like to share the problem I have and how to workaround them.

If you are using previous version of NANT 0.85 to build on .NET 3.0 and 2.0 project, you need to download the NANT 0.86 and unzip to your machine. Next, you will be required to change the environment variable of the NANT path to the bin folder location of the latest version of NANT. Restart your computer and add the following "<property name="nant.settings.currentframework" value="net-3.5" ⁄>" just after the project of the build files. This is enough for you to get your .NET 3.5 project built.

For project involving the reference of System.ServiceModel.dll, you might get some error message will trying to build the project. You will be required to change the referenced dll from the above mentioned to System.ServiceModel.Web.dll which usually can be found in the “Drive:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\”.

Also, the nunit2report is also not working with the current version of NANT. For those preferring to run nunit test report with the nunit2report, you can just copy the following list of files found in the NANT 0.85 bin folder to the 0.86 bin folder and it should work fine:
  1. NAnt.NUnit2ReportTasks.dll
  2. i18n.xsl
  3. NUnit-Frame.xsl
  4. NUnit-NoFrame.xsl
  5. toolkit.xsl
With all this minor changes… everything should be up and running.

Saturday, June 7, 2008

Not forgetting routine

Jett Atwood written a blog about The Greatest Invention in Computer Science and taking it from Steve McConnell, highlighted that routines is one of them. Reading the comments, it seems that not many supported his opinion. Personally, I will not debate on that as I think the scope is just too wide for Computer Science. But I will like to add some of my experience with them.

Learned about routines in the mid 90s when I first started programming in C, I am still religiously using them today in my OOP code. I think the article about routine brought out their importance which I have almost forgotten about them even I use them day in and day out in my code.

Recently, I was doing a lot of code review and was surprise that the concept of routines have been over shadowed by design patterns. Working on project that follows the Test Driven Development (TDD) Technique with a team that is pro to design pattern, some team members have similarly fallen into the design pattern panacea experienced by the author of the Refactoring to Patterns:
The power of patterns led me to lose sight of simpler ways to write code. After learning that there were two or three different ways to do a calculation, I’d immediately race towards implementing the Strategy pattern, when, in fact, a simple conditional expression would have been easier and faster to program-a perfect sufficient solution.

The pro here mean using design pattern without refactoring and doing it up-front with no added advantages that each pattern is suppose to promote. Logic is all coded into one single routine which not only violates the Single Responsibility Principle (SRP) and also increases the difficulties in unit testing. Therefore, I highlighted such code should be refactor into few routines with each routines having it own responsibility. I believe this is the basic of programming and should be practice before any use of design pattern.

I was also thrown interesting debate such as when writing everything in one routine instead of breaking them into a few routines, the call to a routine will not be duplicated. With further discussion, what was going to be duplicated after the refactoring will be one line of code. But this increases the chance of reuse.
Example: A routine that calculate value A and B using a complex formula which B is derived from a complex repository and value A is an input parameter. The calculation and the complex repository are all written in one routine. To separate the added responsibility, the derived of value B should be separated into another routine and probably pass into the calculation routine. But with this, if more than 2 places that need to call the calculation routine will also need to call the routine to derive the value B before the calculation routine. The call to the routine to derive the value B will be duplicated in these 2 places with one single line of code. But imagine the reuse of the calculation routine with a different derived value such as value C.

Writing many lines of codes in a single routine with multiple responsibilities, makes code reading, future refactoring and testing more difficult. So do not forget the basic concept of routine programming over the so called “flexible, sophisticated and elegant” of design pattern.

Tuesday, January 22, 2008

Discussion with Jimmy Nilsson

Last week, my company has engaged Jimmy Nilsson to provide a consultation to a new project that we are working on. During this period, my colleagues and I had an intense discussion with him on topics like Domain Driven Design (DDD) and Test Driven Design (TDD). The discussion has opened up a lot of approaches, concepts and ideas to our new project. New to these topics and having read a few books on them, this discussion really provide a better picture of those missing part found in the books and clear up some of the assumption we have made.

Where is the most complex part of an application? Usually, the domain layer of the application is the most complex part as it contains the different complexity found in different domain. Therefore, design and maintenance of the domain complexity can be one of the greatest challenges in a big project. The
book Domain Driven Design Tackling Complexity in the Heart of Software by Eric Evans provides a good idea of how this challenge can be managed and overcome. Together with TDD and Agile software development approach, the book Applying Domain Driven Design and Patterns: With Example in C# and .NET by Jimmy Nilsson provide another approach of applying the DDD with.

During the discussion, Jimmy has given another definition of his on the TDD, which the focus is not only on testing, but also to be used as a driving tool for the domain design. The idea of this approach is to think and let the design evolve as the codes are written. As a team using this approach, he or she should not be afraid of changes. In software development, what is not changing is the amount of changes that we are seeing throughout the development lifecycle. As for how good the DDD and the Agile approach will turn out to be, I will come back again to review it as the project mature.