Monthly Archives: March 2009

Mocking UserAgent property in ASP.NET MVC with Moq

A question popped up today about someone having trouble mocking the UserAgent property of a Controller. There’s enough information on the Internet with solutions to this problem, so I’m going to describe how to figure it out if you don’t have an Internet connection.

Let’s assume we need to test that our Index action in our HomeController displays the UserAgent information:

   1: public ActionResult Index()
   2: {
   3:     // Don't use ViewData at home kids! This is just a demo
   4:     ViewData["UserAgent"] = Request.UserAgent;
   5:
   6:     return View();
   7: }

Our test would look something like:

   1: [TestMethod]
   2: public void Index()
   3: {
   4:
   5:     HomeController controller = new HomeController();
   6:
   7:     ViewResult result = controller.Index() as ViewResult;
   8:
   9:     ViewDataDictionary viewData = result.ViewData;
  10:     Assert.AreEqual("Mozilla/5.0 ....", viewData["UserAgent"]);
  11: }

If we run this, it will fail with an exception, reason being that Request is null in our test. This makes sense because we’re not coming in from a browser, we’re just calling a method on a class. Therefore, what we need to do is somehow inject a fake Request in there with some value assigned to the UserAgent. The problem is how….

Reflector is your friend

Now, ASP.NET MVC comes with source code that you can download from Codeplex. Having the source code makes it easy to figure out how things work. But we’re assuming that you don’t have an Internet connection remember? And you forgot to download the source code. So let’s fire up Reflector and see what it shows us.

We open up Reflector and load System.Web.Mvc, and locate the Controller class. Since we’re trying to access the Request property of the Controller, that’s the first thing we want to look up:

1

Hmm, it looks like the Request property is really coming from the HttpContext property. Clicking on that gives us:

 

2

We see that the HttpContext is being obtained from the ControllerContext. So let’s continue to drill down to ControllerContext:

3

Aha! Looks like we’ve reached the end. ControllerContext is a read-write property. This means that if we provide a fake ControllerContext in our test, one that contains a fake HttpContext which in turn contains a fake Request with our UserAgent, we’re all set.

 

Working our way backwards

I’m going to use Moq as my mocking framework, but you can use any other framework, such as RhinoMocks.  Instead of trying to declare a whole bunch of mocks first, in a true TDD fashion let’s work our way backwards. First thing we need is a mock ControllerContext. In Moq, the actual mocked object is accessed via the Object property (I’m using screenshots so you can better contemplate the process):

4

As we can see, we’ve added a controllerContext mock object and so the next step is to create this object:

5

Now, our controllerContext needs the HttpContext property set:

6

The lines boxed in red are what we’ve added new. Now that we have our mocked ControllerContext and our HttpContext, the only thing left is to setup the UserAgent property of our Request. But to do that, we need another mock, the HttpRequest object:

7

We therefore create the new mock object and setup the UserAgent property:

8

Our complete test now looks like this:

9

And running it should give us a successful pass!

Refactoring

Now that we’ve understood exactly what’s required, let’s see if we can clean up the test a bit:

10

See what’s happened? We’ve removed the mock objects for both the HttpRequest and the HttpContext. The reason we can do this is because of how Moq works, creating proxies for reference types. Therefore, HttpContext is actually not null, and nor is Request even though we haven’t specifically created a mock for them. This allows us to easily access the UserAgent property and set it to the value required. Saves quite a bit of code

Summary

Mocking can sometimes seem complicated, not knowing what you’re meant to do to get something to work. But all you need to do is take a step back, analyze what is it you’re trying to mock and work your way up. Having tools like Reflector make this easier!

Spending time with Fluent NHibernate (Part 2): Our first Relationship

In the first part of this series, we saw the basics of what Fluent NHibernate is about. In this second part, we're going to look into relationships and some of the mappings that FNH produces for us, as well as overriding certain mappings.

 

Relationships

Let's say we have a new requirement that requires all customers to have multiple documents associated with them.

In terms of a relational database world, if we were to have two tables, one representing customers, and the other documents, the result would be:

 

image

There would be a foreign key in Document pointing to the customer Id of the Customer.

In an OO world, we don't (or shouldn't) care about how information is persisted. In other words, when designing our classes, all we care about is having a list of documents that is related to a customer:

 

   1: public class Document
   2: {
   3:     public virtual int Id { get; private set; }
   4:     public virtual string Code { get; set; }
   5:     public virtual DateTime Date { get; set; }
   6:     public virtual string Author { get; set; }
   7:     public virtual string Contents { get; set; }
   8: 
   9: }
  10: 
  11: public class Customer
  12:    {
  13:        public virtual int Id { get; private set; }
  14:        public virtual string NameFirst { get; set; }
  15:        public virtual string NameLast { get; set; }
  16:        public virtual string Telephone { get; set; }
  17:        public virtual string Email { get; set; }
  18: 
  19:        public virtual ISet<Document> Documents { get; set; }
  20: 
  21:        public Customer()
  22:        {
  23:            Documents = new HashedSet<Document>();
  24:        }
  25:    }

 

Our Customer class contains a collection of Documents (line 19). Why is this an ISet as opposed to an IList or ICollection? A set represents an unordered collection of objects that does not allow duplicates*. Having this class layout, let's put it through Fluent NHibernate to see what it spits out.

 

[* The .NET framework does not come with a type Set. However, all distributions of NHibernate come with the Iesi.Collections assembly, since it's used internally. So you don't have much to worry about.]

 

 

Project Layout

Before continuing, let's take a look at our project layout:

image

We have three projects:

1. Example.Domain which is our application per say. This is where our entities reside.

2. Example.Repository is where our NHibernate repository will eventually be. It is also where our Mapping configuration is located.

3. Example.FluentHelpers is a series of classes that will help with generating the database structure, etc.

The reason that our Mapping file is kept in the repository is two-fold:

1. FluentHelpers can be re-used and is project independent. It knows nothing of specific entities or mappings.

2. Domain should have no reference to the persistence mechanism and as such should not know whether we use NHibernate or any other type of ORM.

Our FluentMapper class is just a wrapper around Fluent Nhibernate and NHibernates tools namespace, with three methods: SaveMappings, CreateDatabase and UpdateDatabase. The SaveMappings exports the mappings Fluent NHibernate creates for us to a specific folder (remember, each class has it's own mapping). The implementation is very straight forward:

 

   1: public void SaveMappings(string path)
   2: {
   3:     _persistenceModel.WriteMappingsTo(path);
   4: }

 

As for our mapping configuration, NHMapping, this is where we'll eventually add specific configurations overriding Fluent NHibernate's default settings. But for now it's just that one line of code. The reason is returns an AutoPersistenceModel is because this is what we pass into our FluentMapper to actually do the work.

 

   1: public static AutoPersistenceModel GetMapping()
   2: {
   3:     return AutoPersistenceModel.MapEntitiesFromAssemblyOf<Customer>();
   4: }

 

Generating Mapping Files

Once we put all this code together, we can see the mapping Fluent NHibernate generates for us. To make things easier, I've included a MSBuild task (FluentTask) that does this, along with creating/recreating databases if required (works great as part of an integration test). Here's a sample MSBuild project file to generate the mappings for us:

 

   1: <?xml version="1.0" encoding="utf-8" ?>
   2: <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   3:   <UsingTask AssemblyFile="Example.FluentHelpers.dll" TaskName="FluentTask" />
   4:   <Target Name="Default">
   5:     <FluentTask
   6:       PersistenceModel="Example.Repository.dll, Example.Repository.NHMappings, GetMapping"
   7:       ConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=FluentExample;Integrated Security=SSPI"
   8:       MappingOutputFolder="C:\Temp"/>
   9:   </Target>
  10: </Project>

 

For illustrative purposes (i.e. this is NOT needed if you're using Fluent NHibernate), let's see the generated output for our classes:

Customer.hbm

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Example.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" namespace="Example.Domain">
   3:   <class name="Customer" table="`Customer`" xmlns="urn:nhibernate-mapping-2.2">
   4:     <id name="Id" type="Int32" column="Id">
   5:       <generator class="identity" />
   6:     </id>
   7:     <property name="NameFirst" type="String">
   8:       <column name="NameFirst" />
   9:     </property>
  10:     <property name="Telephone" type="String">
  11:       <column name="Telephone" />
  12:     </property>
  13:     <property name="Email" type="String">
  14:       <column name="Email" />
  15:     </property>
  16:     <property name="NameLast" type="String">
  17:       <column name="NameLast" />
  18:     </property>
  19:     <set name="Documents">
  20:       <key column="Customer_id" />
  21:       <one-to-many class="Example.Domain.Document, Example.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  22:     </set>
  23:   </class>
  24: </hibernate-mapping>

 

Document.hbm

 

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Example.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" namespace="Example.Domain">
   3:   <class name="Document" table="`Document`" xmlns="urn:nhibernate-mapping-2.2">
   4:     <id name="Id" type="Int32" column="Id">
   5:       <generator class="identity" />
   6:     </id>
   7:     <property name="Author" type="String">
   8:       <column name="Author" />
   9:     </property>
  10:     <property name="Date" type="DateTime">
  11:       <column name="Date" />
  12:     </property>
  13:     <property name="Contents" type="String">
  14:       <column name="Contents" />
  15:     </property>
  16:     <property name="Code" type="String">
  17:       <column name="Code" />
  18:     </property>
  19:   </class>
  20: </hibernate-mapping>

 

The interesting part is line 19 – 22 of the Customer.hbm. What this is saying is that there is a relationship of one to many from Customer to Document, indicating the class corresponding to Document. It also indicates that the foreign key in the Document table is Customer_id. To create the database, we can add the attribute DatabaseOperation="Create" to our MSBuild task and it will create the database for us:

 

image

 

Overriding specific mappings

As you may have noticed, all of the string types are automatically mapped to nvarchar(255). This is what NHibernate does by default if a length attribute isn't specified in the property mapping. Considering our Contents property for Document requires a larger amount of data to be stored, we need to override this. For these cases, Fluent NHibernate allows you to override a specific mapping of an entity by using the ForTypesThatDeriveFrom method:

 

   1: public static AutoPersistenceModel GetMapping()
   2: {
   3:      return AutoPersistenceModel.MapEntitiesFromAssemblyOf<Customer>()
   4:          .ForTypesThatDeriveFrom<Document>
   5:            ( m => m.Map(p => p.Contents).WithLengthOf(3000));
   6: }

 

In this particular case, we're telling Fluent Nhibernate, that when mapping Document (and it's descendants), the property Contents should be mapped with a length of 3000 characters. Any other property not specified will still be mapped using the defaults. Making this change, we'll end up with a database column of type nvarchar(3000), with everything else, exactly the same. 

 

 

Summary

In this second part, we defined a relationship between two entities and Fluent NHibernate figured out the rest for us. As we continue with this series, we'll see that as our entity model becomes more complex there are situations where we have to "help" Fluent NHibernate a little bit with the mappings. 

 

Credits

I'd like to thank James Gregory, not only for the wonderful work he's doing with Fluent NHibernate, but also for reviewing these entries to make sure I haven't said something stupid and give the wrong information to my readers.

ASP.NET MVC or WebForms: Is there a real choice?

I've been playing with ASP.NET MVC from the first preview that was released, and it's also very similar to a technology I used to use back in 1998, called WebBroker (part of Delphi). Point being, I'm pretty comfortable with the MVC approach. I also have had the opportunity to do talks and workshops on ASP.NET MVC recently, and one of the questions that come up frequently is whether or not people should use ASP.NET MVC or stick with WebForms. Generally my answer is, if it's a new application, go with MVC. If it's an existing ASP.NET WebForms application, stick with it, unless it is causing maintenance nightmares, requires continuous work and expansion, then it might be worthwhile considering a port (read rewrite) to ASP.NET MVC.

In this post, I'm not going to make a side-by-side comparison of ASP.NET Classic (from now on referred to as ASP.NET) and ASP.NET MVC (from now on referred to as MVC). I'm going to concentrate on a few of the "disadvantages" that are normally associated with MVC and give you my thoughts on why I think they are not really a disadvantage.

 

1. Step learning curve.
WebForms was pretty much born for WinForm developers to port their applications to the Web. The idea was to leverage the existing knowledge of developers and not have them learn a whole new set of concepts to make their application "web-enabled". It worked around HTTP's stateless nature, hid concepts such as Javascript, HTML and CSS. In turn it added things like ViewState, the ASP.NET Page lifecycle, Server-Side all purpose controls, where a control had multiple responsibilities including rendering, handling postbacks, event management, etc.  as well as unfriendly URL's, cryptic and in general bloated HTML output.

As such, one of the arguments against MVC that's usually made is that it has a steep learning curve, that you need to understand concepts such as HTML and Javascript. That is true, we're dealing with a thing called "Web" which is based on things such as HTML and Javascript and CSS, so it's not that far fetched. In addition, many ASP.NET veteran developers know that you can't get by any serious web application without ever having to touch Javascript. Having said that, the learning curve is not that steep, once you lose the webophobia.

 

2. Lack of Server Side Controls.
In MVC there's no concept of server-side controls. The immediate reaction to this is that we lose the drag-and-drop grids, dropdowns, calendar pop-ups, etc. However, these server-side controls with amazing functionality aren't magic. A lot of the functionality is done via client-side Javascript. A couple of years ago, this could pose a problem. Today, with libraries such as jQuery it doesn't. You want a drop-down calendar on ALL your textboxes on the form, all you need to do is add one line:

      $("input").datepicker();

It's not drag-and-drop, but then again, it's not that complicated either. The same goes for grids, auto-complete components, etc.. There's a whole community of controls (and most free).

 

3. Lack of RAD Development
At my sessions, as I start showing people what MVC is about, I can see faces thinking "I have to now write all this by hand again" or "here comes the 90's all over again". Yet, when during the same session 20 minutes later, I show them how you can put together a CRUD application in very short amount of time, you can see the sparkle in their eyes. The lack of RAD in MVC comes from the wrong assumption that since there aren't concepts such as ObjectDataSource or drag-n-drop controls, it's slower to create application.

MVC offers it's own solution to creating RAD application. To start with, there is a complex and extensible object binding under the hoods. This means that I can declare a method (action as it's known in MVC) that can take a complex type (with it's graph of subtypes) and have two-way binding out of the box.  In terms of data, one of the advantages of the MVC framework is that it doesn't impose a specific model. You can use Web Services, Linq 2 Sql, NHibernate, whatever you want. You can even use Dynamic Data Services. Therefore the time it takes to consume a model is irrelevant of whether you use MVC or ASP.NET.

Out of the box scafolding, support for T4 templates jQuery add all the RAD'ness without the disadvantages. You get to do RAD development, yet at the same time, maintain a clear separation of concerns.

 

4. Losing some of the ASP.NET Framework
MVC is built on the ASP.NET framework. Therefore, things such as Membership, Master Pages, Session Management, Localization, Forms Authentication, etc. are all there. You don't lose any of that.

 

5. Re-use of code
Many people have been creating ASP.NET Web applications using the MVP pattern. The main advantage that this gives, apart from the obvious separation of conerns, is that you are left with a Presenter that you can ideally re-use in both your Web application as well as your Desktop application. Although this might seem a good idea at first, in reality it probably means that you have let business logic leak into your Presenters, which is not a good thing. With MVC for example, the Controller's only concern should be to act as a bridge between the Model and the View. This normally is translated into 2-3 lines of code.

It should never make business decisions.

 

Summary

The above are only some of the so-called disadvantages of using MVC. I've not even talked about the advantages, being the post would be too long. However, here are a few highlights:

  • Clean Separation of Concerns
  • Complete Control and Clean HTML Output
  • SEO Friendly URL's
  • Test Friendly (even TDD)
  • Clean Integration with Ajax (no need for Web Services, PageMethods or Page load hacks)
  • Extensible and Customizable
  • Support for multiple View Engines

There's one typical argument that I've heard of wether you should use MVC or ASP.NET. They say that MVC is a good choice when you want to create testable and maintainable applications. Well, in my book, I ALWAYS want to do that so really it's not a valid argument.

To be entirely fair though, I do see one disadvantage with MVC: there's not enough hosting companies out there that support .NET 3.5. But it's just a matter of time…

Spending time with Fluent NHibernate: Part 1

A couple of days ago, there was a post by Howard Dierking covering the topic of Fluent NHibernate. What caught my attention was one of the comments:

I find this a little weird… isn't it so that in general, nhibernate supporters loath the 'domain model following the database tables' approach, while to get automapping, you practically have to? ;)

About the PI issue: there's no such thing as persistance ignorance: whatever persistence logic you're using, it bleeds into your own code one way or the other, be it a base class, be it requirements how to define properties/members, be it how to deal with 2-sided relationships etc.

 

I want to focus the following series of posts on showing what Fluent-NHibernate (NHibernate) is truly about, and let you be the judge of whether the previous comment is correct or not. My stand on it is that it's not.

So without further ado, let's start by the basics.

[Note: Due to time limitations and also to keep posts short, I will try and focus on small sections on each post]

 

NHibernate 101 in one paragraph

For those new to NHibernate, it is an ORM framework (Object Relation Mapper). ORM's try and eliminate the impedance mismatch that exists between Object Orientated programming and Relational Databases. This allows developers to work with objects and not have to worry about how these objects are persisted to disk in a relational database (i.e. tables, joins, etc.). Other examples of ORM's include LLibGenPro, Linq to Sql, and of course Entity Framework (although some people claim that EF is MORE than a ORM, but each to their ow).

 

Mapping in NHibernate

One of the main problems with any ORM is that there is considerable amount of time spent mapping objects to their corresponding tables in a database. Imagine the following class:

   1: public class Customer
   2: {
   3:     public virtual int Id { get; private set; }
   4:     public virtual string NameFirst { get; set; }
   5:     public virtual string NameLatst { get; set; }
   6:     public virtual string Telephone { get; set; }
   7:     public virtual string Email { get; set; }
   8: }

This needs to be stored in the database somehow, and to do so, the framework (in our case NHibernate), needs to know how to match objects to tables and properties to columns. To solve this, NHibernate uses the concept of mapping files (hbm), which are non other than XML files with specific tags:

   1: <?xml version="1.0" encoding="utf-8" ?>
   2:  <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
   3:    namespace="Examples.Domain" assembly="Examples.Domain">
   4:
   5:   <class name="Customer" table="Customer">
   6:      <id name="Id">
   7:       <generator class="identity" />
   8:      </id>
   9:      <property name="NameFirst"/>
  10:      <property name="NameLast"/>
  11:      <property name="Telephone"/>
  12:     <property name="Email"/>
  13:  </class>
  14:</hibernate-mapping>

The configuration is pretty self-explanatory. You define the name of the class, the corresponding table name you want in the database, and then start to define a series of properties. NHibernate follows a series of conventions, so for example if a column attribute is not specified in the property element, the corresponding column name in the database table will be the same as that of the property. The same thing happens with the type of the property, again, NHibernate internally maps CLR types to database types.

One of the problems with this type of mapping is that you don't get type-safety. If you make a mistake in writing out a column name you won't know of the issue until runtime. The other problem occurs when you are trying to refactor your code. If you don't have special add-ons such as Resharper (and if you don't, what are you waiting for?), refactoring XML files is pretty much a no-no in Visual Studio. Imagine the scenario: you rename NameFirst to FirstName and forget to do it in your mapping file. Your application will still compile, but come runtime, kaboom!

 

Fluent-NHibernate 

This is where Fluent-NHibernate enters the picture. This project was initially built to allow for developers to map their entities to tables in code, i.e. using C#.

   1: 1. public class Customer : ClassMap<Customer>
   2: 2. {
   3: 3.   public Customer()
   4: 4.   {
   5: 5.     Id(x => x.Id);
   6: 9.     Map(x => x.NameFirst);
   7: 9.     Map(x => x.NameLast);
   8: 9.     Map(x => x.Telephone);
   9: 9.     Map(x => x.Email);
  10: 2.   }
  11: 3. }

Already this provides benefits. By allowing this, you get away from the magic strings in the mapping files, allowing not only for compile-time checking but also refactoring.

However, one thing still remains, mapping. You still have to map your classes. Now, during both the mapping using XML as well as C#, have you noticed one thing? A series of assumptions are made. We said previously that you don't need to specific column names or types, etc. These are conventions. NHibernate assumes a series of conventions. Following the 80/20 rule, assuming that 80% of the time these conventions suit our applications, there's a remaining 20% that would  need some sort of adjustment.

 

Auto Persistence Model

Say Hello to the Auto Persistence Model in Fluent-NHibernate. By latching on to the concept of convention over configuration, the Auto Persistence facilities in Fluent-Nhibernate do the mapping for you. This makes a series of decisions and maps your classes to their corresponding database tables and columns. Yet at the same time it  allows you to tweak these conventions. This then gives us 100% coverage. For 80% of the time, the APM is fine, and for those special cases we adjust the conventions to our needs. Here is the same mapping using the Auto Persistence Model in Fluent-NHibernate:

   1: AutoPersistenceModel.MapEntitiesFromAssemblyOf<Customer>().Configure(config);

AutoPersistenceModel has a static method MapEntitiesFromAssemblyOf where you pass in a specific type. Since my current example only has one type, namely Customer, I'm passing this one in. It takes this assembly and loads all the types it contains and create the NHibernate mappings for you. It places these mappings into a NHibernate Configuration class (the config parameter).

So far, the code for the simple example project is limited to the Customer class and the single isolated line of code that generates the mapping using Fluent-NHibernate's Auto Persistence Model. However, on it's own it's pretty useless. We need to somehow tie it to a database (that doesn't exist yet) so that we can actually make use of it. To do so, we create a Mapper class that generates the mappings and returns the NHibernate configuration:

   1: public static class Mapper
   2:    {
   3: 
   4:        public static Configuration GenerateMapping(string connectionString)
   5:        {
   6:            var config = MsSqlConfiguration.MsSql2005
   7:                .ConnectionString(c => c.Is(connectionString))
   8:                .ConfigureProperties(new Configuration());
   9: 
  10:            AutoPersistenceModel.MapEntitiesFromAssemblyOf<Customer>().Configure(config);
  11: 
  12:            return config;
  13: 
  14:        }
  15: 
  16:    }

What this class is doing, is create a NHibernate configuration that is based on Microsoft SQL Server (2005 and up) and configures a series of default properties. The only parameter it requires is the connection string. It generates the the mapping files and returns the configuration to us. Next step is to make use of this configuration. Remember, right now we have the mappings, but we don't actually have any underlying database. We don't know anything about how the structure is or should be.

 

Creating the database

In the NHibernate framework, there is a namespace called hbm2ddl which as it's name indicates, can create DDL from mapping files. That is precisely what we need. To use it, it's as simple as passing in a NHibernate configuration to the SchemaExport class:

   1: using NHibernate.Tool.hbm2ddl;
   2: 
   3: namespace Example.DBGenerator {
   4: 
   5:
   6:     class Program
   7:     {
   8:         static void Main(string[] args)
   9:         {
  10:             var config = Mapper.GenerateMapping(args[0]);
  11: 
  12:             new SchemaExport(config).SetOutputFile(args[1]).Create(/* Output to console */ false, /* Execute script against database */ true);
  13:         }
  14:     }
  15: }

Ignoring the fact that there is absolutely no error checking in this application whatsoever, all we are doing is taking the our configuration generated by the mapper and passing it to our SchemaExport class, which is calling the Create method to create the SQL, dump it into a file and at the same time, generate it for us in SQL Server. Running this executable with the following command line:

"Data Source=.\SQLEXPRESS;Initial Catalog=FluentExample;Integrated Security=true" Output.sql

we get:

 image

 

 

Summary

In this first post, I wanted to show you how you can easily create a domain model and have the corresponding database created for you automatically, without having to worry about any types of mappings, let alone database structures. However, I've only touched the tip of the iceberg. In the next series of posts, we'll drill down into everything Fluent-NHibernate has to offer us.

Coming back to the original comment, what do you think? Did I start with my domain object or my database? This is what true persistence ignorance is about!

Profiling NHibernate with NHProf

There's a common conception that developers suck at creating user interfaces. And it's probably right on target. One of the reasons is that, as developers, we look at things differently than a normal user would. And usually this causes problems, except in one scenario where it's an advantage: when our end users are of our own species. NHProf fits that bill perfectly.

Along with Balsamiq, which I blogged about a few days ago, NHProf is the other tool that I had a chance to play with this week, and I'm pretty excited about it. For those of you who don't know what it is, NHProf is a profiler for NHibernate, created by Ayende.

One of the characteristics of NHibernate is it's extensive logging support, and using log4net, NHibernate can log almost anything that happens. However, it's not always easy to read this information, let alone debug what's wrong.

NHProf tries to fix this shortcoming by offering a visual and extremely useful interface that provides relevant information you need to understand what's going on under the covers and help you improve performance of your application. And if that weren't enough, in a true fashion, inline with tools such as Resharper, it even offers you tips and recommendations.

image

I'll be posting more about this tool as I play with it. It's really got me excited. It comes with a 30 day trial so make sure you check it out. 

Podcast from Oliver and Gary

Oliver Sturm and Gary Short, from DevExpress have started a new podcast. Having recently met up at a conference in Germany, they decided to make me their guinea pea. Thus if you’re interested in hearing two ugly guys (and myself) talk about a bunch of different things, check it out. The only thing that doesn’t surprise is what they’ve called it.

It was fun guys. Thanks!

 

(P.S.: I talk about another Podcast in it but I won’t spill all the beans just yet….)

ASP.NET MVC and jQuery @ BASTA! Italia

I'm off to Rome next week for BASTA! Italia, and quite excited since it's my first time in Italy. Mind you, I always say that but my trips normally involve

Airport -> Hotel -> Conference Venue -> Hotel -> Airport

And that's if the Conference is not held at the same Hotel. In this case, it is :) .

Having said that, it will be good to catch up again with friends and eat my all-time favorite food (Pasta) in it's country of origin.

I'll be giving two talks which I thoroughly enjoy

  • Introduction to ASP.NET MVC
  • Introduction to jQuery

 

See you there!

Balsamiq. Just wow!

 

Busy week for me this week. Between meetings, coding and real bad case of migraine, I’ve hardly had time to catch up with blogs or investigate new things. However, I did find a bit of time to look at two new tools, one of them being Balsamiq (the other tool, another blog post). I’d heard about Balsamiq some time ago but never really got round to playing with it until this week. And all I can see is that it’s damn awesome.

What is it? It’s a tool to do mock-ups of UI’s. What makes it awesome (apart from the really low price tag), is that it’s extremely easy to use and powerful at the same time. Take a look at some screen mock-ups

image

And here’s the iPhone version of the "application"

 

image     image

So in 5 minutes (literally), I threw up a few mock-ups of some UI that I can then show the customer. The cool thing is that it’s so easy to use, you can actually have meetings with the customer using Balsamiq and come up with a design together. Here’s an image of the the surface design with some random controls:

 

image

I remember when I was doing mock-ups years ago using RAD tools like Delphi / Visual Studio. Man does this save time.

Love it! Definitely it’s on my must-have-tools list. If you do any type of UI mock-ups, I highly recommend it.

Few days left for Early Bird for Architecture Days

Just a few days left for the Early Bird fee for the iMeta Architecture Days. It’s going to be a two day event in Madrid on Design Principles, Testing, and on the second day Domain Driven Design and SOA with Udi Dahan!

Since it’s a training event, it’s going to be a small group so there’s more room for interaction.  And all this is for just a mere 375 Euros. Price includes lunch and munchies on both days.

To sign up and more info, click here