Thursday 18 February 2010

Test Driven Development

 

             When sitting down to create an application, many developers start by writing the code. Test Driven Development emphasizes the opposite, stressing the need to prepare test scenarios or test cases before writing the code itself. This seemingly backwards approach has some benefits. First of all, it requires that the programmer be very clear about what tests the program should pass and what test it should fail, bringing such concerns to the forefront of the software design process. Furthermore, by meticulously detailing what tests a system should pass and fail we can use tools to automate most of our tests. An automated job is one that's always very, very easy to do. These automated tests are meant to be run every time there's a code change and are referred to as unit tests.

NUnit is a free, open-source tool for .NET that is developed as a framework which can help automate unit testing. (The same unit test framework was already available for Java and was named jUnit.) NUnit can be downloaded from NUnit site or the SourceForge NUnit page.

http://www.4guysfromrolla.com/articles/011905-1.aspx

http://www.codeproject.com/KB/dotnet/tdd_in_dotnet.aspx#h2

Wednesday 17 February 2010

ASP.NET MVC

 

Model-View-Controller

The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes :

  • Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

  • View. The view manages the display of information.

  • Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

Figure 1 depicts the structural relationship between the three objects.

ms978748.des_MVC_Fig01(en-us,MSDN.10).gif

 

ASP.NET MVC is Microsoft framework for building web applications that use a model-view-controller pattern. ASP.NET MVC is built on the ASP.NET framework.

ASP.NET MVC provides the following benefits:

  • Provides complete control over your HTML markup.
  • Enables rich AJAX integration
  • Intuitive website URLs
  • Clear separation of concerns which results in web applications that are easier to maintain and extend over time.
  • Testability – including support for test-driven development.

For Developing Applications using MVC and to use entity framework for adding ADO.NET entity Data Models you need to have .net 3.5 and service pack 1.

The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc namespace and is a fundamental, supported part of theSystem.Web namespace.

http://www.asp.net/learn/mvc/tutorial-01-cs.aspx

 

Problems:

 

While trying to do a sample application i got the following problems:

1. ADO.Net Entity Data Model not a selectable option when I go to add an item.

Linq to Entity Framework is shipped with Visual Studio 2008 SP1. So in order to use it, we need to apply the Visual Studio SP1

http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en

2. While trying to install sp1 i got the following error saying :

Installation Requirements:

You must first use <A HREF="http://go.microsoft.com/fwlink/?LinkID=121685">Microsoft Visual Studio Patch removal tool</A> before installing Visual Studio 2008 SP1.  The tool will verify Visual Studio integrity and remove previous Visual Studio 2008 updates or pre-release software
Microsoft Visual Studio 2008 - KB945140 (Beta)

image

Visual Studio 2008 Service Pack Preparation Tool must be installed inorder to avoid this error.