TDD & MVC 06 – Fluent NHibernate Prototype (out of the box)

While I would love to jump straight into my problem domain design/ documentation I have the steep learning curve of Fluent NHibernate.  The out of the box prototype will consist of;

  • Real database schema (already scripted with dummy data).
  • Data DLL using Fluent NHibernate.
  • Simple MVC website with hard coded methods.

The aim is to focus on Fluent NHibernate but to remain within a simple architected and MVC environment.

Setting up Fluent NHibernate;

  • Followed the wiki to get svn source code
  • Successfully built the FluentNHibernate project.
  • Copied the FluentNHibernate project’s bin contents to my Data DLL’s lib folder.  FluentNHibernate generated these DLLs;
        • Antlr3.Runtime.dll
        • Castle.Core.dll
        • Castle.Dynamic.Proxy2.dll
        • FluentNHibernate.dll
        • Iesi.Collections.dll
        • log4net.dll
        • NHibernate.ByteCode.Castle.dll
        • NHibernate.dll
        • and nhibernate-mapping.xml
  • Wrote two basic Entities (Person and Title) in the Data DLL.
  • Wrote an ISessionFactory property for the Fluent NHibernate session.
  • Wrote a Fluent NHibernate init call in the web’s Application_Start() event (Global.asax).
  • MVC HomeController set two ViewData objects to Person collection and Title collection.
  • Index view looped the ViewData objects … OMG it just worked out of the box!!  This all took about 2 hours, including making 2 coffees :)

Well done Fluent & NHibernate :)

Back to the TDD & MVC Adventures landing page

Balsamiq and software mockups

A wee while ago I posted a picture speaks a thousand words.  Well Balsamiq have just made my life even easier with their Balsamiq Mockups software which create software mockup visuals in minutes.

Do not understand “visuals in minutes” as limited/ cheap software capabilities, instead understand “visuals in minutes” as incredibly easy/ intuitive/ building block mechanism which just works.

Balsamiq make two bold statements;

  1. Get to Agreement Early.  With a tool everyone can use.
  2. Cut down spec-writing time.  Spend your time coding, not churning.

From a brief evaluation of the product I can see these bold statements being true as during the sales pitch process designers can mock up visuals quickly, but this is still a cost of (hopeful) sale.  With Balsamiq Mockups software sales people were able to make quick and efficient demo’s to clients and answer those common UI decision all within a single meeting which not only increased client confidence it sped up the sale process, reduced the sale’s persons write up stage (and we all know how poor sale’s people are at writing up those intricate details!!), improved the sale’s person accuracy … *easier software process here* … the end result was a better quality product as more time was spent coding the software rather than reams of documentation.

Happy Balsamiq Mockup'ing :)

TDD & MVC 05 – Problem domain and Fluent NHibernate

Problem domain – the area which is being examined in order to find a solution.  For example; an ecommerce shopping engine’s problem domain contains areas such as products, a shopping basket and a checkout NOT areas such as warehouse product picking or postal delivery logistics.

NHibernate - NHibernate is a mature, open source object-relational mapper for the .NET framework. It's actively developed , fully featured and used in thousands of successful projects.

Fluent NHibernate - Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate.

What is the point of these three definitions??  Well having read my MVC books, I was in a development mind shift mood and as such decided to reflect on key development areas/ tools I have successfully been using for many years to determine their value within a TDD & MVC approach.

Over the years Object Relational Mappers (ORMs) have become more common and have made significant progress in their efficiency and usability.  To date I have never felt the need to use them due to having re usable data layer plumbing and enjoyment of hand crafting business objects.  However, is this approach truly spending time on the problem domain?

Yes – because valuable time is being spent ensuring the business objects are of the correct shape to solve the problem domain.

No – because value time is being spent on writing CRUD operations for the business objects.

To date I have not had any timeframe/ time cost problems with hand crafting business objects.  However, is there now the opportunity to improve timeframes/ time costs??

No – the learning of new frameworks takes a significant amount of time to not only concept prove but to implement correctly.

Yes – because the currently available tools and approaches have long term timeframe/ time cost savings that are re cooped after a few projects.

What tools and what approaches am I going to adopt??

The TDD & MVC books detail an approach which focuses on strictness in identifying/ testing the problem domain.  With which comes quite a lot of extra work with authoring both test projects and the actual software projects.  However, the resulting software development aims to deliver a more verified, validated and robust product.

So where can I now save some time?  An ORM to produce business objects with all CRUD … enter Fluent NHibernate which, as with MVC, adopts the convention over configuration design paradigm out of the box.  So based on convention (stemming from the database) I can ensure the business objects will appear as I would like without spending time hand crafting.

The steep learning, hopefully beneficial, learning curve begins :)

Back to the TDD & MVC Adventures landing page

Crawling and Indexing

After watching Matt Cutts – Learn more about robots.txt video I wanted to clarify my understanding of similar but significantly different SEO terms such as crawling/ showing results/ page fetching.

I use robots.txt to block Google from crawling a specific URL but the page is still showing up in Google results.

Standard results;

Capture

What is actually showing up in Google results is the robots.txt blocked URL with NO description/ snippet.

Capture2

So how has the blocked URL got in the search results???

There are inbound links to the blocked URL and while I do not want the search engines to crawl the URL there are people out there who believe the URL is authorative.  As such the URL will be displayed in the Google results yet it has NOT been crawled.

However, there are examples where robots.txt blocked URLs actually have descriptions/ snippets in the search results despite not being crawled.  How is this; well Google wants to provide users with information and if a link is deemed authorative by many users then Google could look for reference information in sites such as The Open Directory Project to use as the description.

Can’t hide information from the masses – this is great.  However, for whatever reason I really don’t want this URL to be listed at all.  How can I achieve this?

1. Use the no index robots meta tag. Google webmaster explains the the usage too.  However, do for the meta tag to be seen, the crawler needs to fetch the page!  So make sure the URL is removed from the robots.txt file.

2. Google specific is to use the Google URL removal tool.

Happy roboting and thanks Matt.

PS coming soon will be an update on Matt’s article of how the different crawlers respect the no index robots meta tag.

Microsoft's Courier booklet – Infinite Journal

I really hope the final rtm version keeps up with these teasers (in date order ascending);

  1. Gizmodo - Leaked Courier Video Shows How We'll Actually Use It 
  2. ZDNet - Microsoft's Courier tablet: A Franklin Covey planner on steroids?
  3. http://mashable.com/2009/11/04/courier-ui/ 
  4. http://gizmodo.com/5380626/courier-user-interface-in-depth

And I hope the price is sensible(ish) but I WANT ONE !!!!!

TDD & MVC 04 – making sense of MVCs folder naming convention strictness and action View()

It is obvious, after having played with MVC for a very short time, that MVC adopts the convention over configuration design paradigm out of the box.  For example; all Controllers should be suffixed with Controller and be stored in the Controllers folder.

One thing I noticed was the inevitable spaces in folder names.  In short don’t use spaces!!!

  1. Added MakingSenseController.cs to the Controllers folder.
  2. Added “Making Sense” (note the space) folder to the Views folder.
  3. Added Test.aspx under the “Making Sense” folder.
  4. Added the appropriate routing link.
  5. Ran …

Capture

So what is the MVC framework doing?

   1: public class MakingSenseController : Controller
   2: {
   3:     public ActionResult Test()
   4:     {
   5:         return View();
   6:     }
   7: }

The MakingSense controller Test action is simply returning the View() but what is the View().  It is actually taking the name of the controller (MakingSense) and assumes there is the same named sub folder to the main Views folder.  Then under the MakingSense folder is the Test.aspx view.

But we know this is not the case because I have violated the conformation and added a space to the folder name.  If you really want spaces or something slightly different then the returned view can be explicitly defined;

   1: public class MakingSenseController : Controller
   2: {
   3:     public ActionResult Test()
   4:     {
   5:         return View("/Views/Making Sense/Test.aspx");
   6:     }
   7: }

In my opinion the whole point of adopting MVC and conventions in general is you STRICTLY adhere to the conventions otherwise your code could be very hard coded with name changes/ broken conventions etc.  As such I removed the space from the “Making Sense” folder which resulted with a successful redirection using the convention based code;

   1: return View();
 
Happy compliant strictness :) and back to the TDD & MVC Adventures landing page.

TDD & MVC 03 – the test project templates

On successfully creating my first MVC application, you will notice the only Test project option was that of Visual Studio.  I am interested in adopting NUnit, primarily because all my close technical colleagues are all happy using NUnit.

Thanks to the Visual Web Developer Team Blog in providing a step by step approach to not only adding third party project templates into Visual Studio but providing configuration and templated MVC test projects for NUnit and NUnit with Rhino Mocks.

Back to the TDD & MVC Adventures landing page

TDD & MVC 02 – The visual studio template

Having installed/ downloaded;

I was ready to create my first MVC web application.  So I opened up Visual Studio, File, New, Website and was presented with;

Capture

Oh gosh, where is the MVC template???  Did I miss something???  No I did not you actually have to use menu items; File, New, Project;

Capture

And there MVC template appears.  Phew!!!

Happy MVC’ing and back to the TDD & MVC Adventures landing page.

TDD & MVC 01 – the books

Ok for a myriad of reasons I have decided to adopt a true TDD approach alongside MVC with my next large development project.

The books I read;

The main reasons for the above books were not only recommendations but also the two ASP .NET Problem – Design – Solution WROX series are great for starting applications from scratch through to completion with good practice refactoring in between.

The starting place for web information is always – ASP .NET MVC.

Back to the TDD & MVC Adventures landing page

TDD & MVC adventures

Ok for a myriad of reasons I have decided to adopt a true Test Driven Development (TDD) approach alongside Model View Controller (MVC) with my next personal large development project.  This is the blog series landing page to help navigation :)

… and anything else that I get side tracked on to :)