Saturday 15 October 2011

Using NCover with Cruise Control.NET and Nant

I had the task of integrating NCover into our continuous builds and integration. At the time I was using Cruise Control.NET v 1.5, NCover v 3.4.18 (classic), and Nant v0.91. I came across several problems when doing this, however I finally came across a solution where by using Nant I was able to build my application, run my Nunit tests and the run my coverage. The route I took involved using the NCover Nant task DLL that comes with NCover and running it over my tests. The issue which held me up the longest was the fact that in order to run coverage over your test DLLs you need to ensure that you include the pdb symbols in your build output, otherwise you'll be going nuts!

Sunday 9 October 2011

IOC - Inversion of Control

Currently, I'm using Inversion of Control (IOC) for most of my application building which I'm finding really useful and quite powerful. Some people consider IOC to be a pattern which follows the three R's: Register, Resolve and Release which is how you would use it by default. IOC usually takes some kind of container which holds all the mappings between objects, for example, if you wanted to use the class Chicken everytime you referenced the interface IAnimal then in you container you may have the following registration: _container.Register.To(); The syntax depends on which IOC library you are using; there are several. My current preferred choice of IOC library is Castle Windsor, which makes using IOC inside applications quite fun and simple.

Sunday 10 July 2011

ASP.NET MVC

Hi all, I'm back after a long time off. What I would like to discuss is ASP.NET MVC in comparison to ASP.NET.

Let’s give a quick introduction ASP.NET (Active Server Pages) is a server side coding language used for rendering HTML (Hyper-Text Markup Language). This is achieved by using the notoriously infamous server tags <% code goes here %>.

The ASP.NET runtime was built as an abstraction to allow developers to code in their native .Net languages, e.g. C# to create powerful web applications. The problem (amongst other things) was that the level of abstraction meant that coding “simple straight-forward” applications was quite easy and efficient, however coding custom or complex applications became quite difficult, e.g. two form tags on the same page.
The main problem was that through this level of abstraction some granular control was taken away from the developer in order to have a windows forms style development experience. Even controlling Ids on a particular HTML element became quite a laborious and painful task.

With ASP.NET version 4.0 some vast improvements had been introduced to make most coding scenarios easier, however with the revolution of test driven development, the improvements (in my opinion) still weren’t enough – introducing ASP.NET MVC.
MVC (Model View Controller) for those who do no t know is a design pattern used throughout all kinds of programming languages. It essentially boils down to one primary concept “separation of concerts”, meaning everyone has a job and they should only be concerned with fulfilling the requirements of their job. Fox example, in a typical restaurant theirs a chef, a waiter, and a manager. It’s not chef’s responsibility to take your jackets and make sure your comfortable in your seat, just like it’s not the waiter’s responsibility to ensure that the restaurant’s targets are met and that everyone shows up to work on time.

The MVC design pattern has been so successful in coding web applications that Microsoft and the ASP.NET team decided to introduce their own implementation. What this means is that we now have a design pattern directly “embedded” into the .NET framework, and used correctly can lead to power web applications as with ASP.NET but also powerful unit testing. ASP.NET MVC gives some of the control back to the developer and allows you to deepen your understanding of ASP.NET runtime.

With ASP.NET MVC 3.0 there is a new syntax introduced for creating ASPX pages called Razor. It is what I would describe as very clean and concise. The reason being that a lot of the repetitive tags and directives are no longer needed and writing C# inline with HTML (or even JavaScript) looks a lot nicer to read! Which for some developers such as myself is very important. What this means that less keystrokes are now required to produce the same content with ASP.NET thus allowing the developer to get on with other important tasks, such as, poking people of Facebook.