November 2008 - Posts

Ordering Form Collection Parameters For MonoRail using jQuery

Mike Nichols wrote a neat jQuery plugin to automatically order a list of items (like <TR>'s or <UL>'s).  This plays very nicely with MonoRail's SmartDispatcherController and DataBind attribute:

"... to keep the items in a collection (like table rows or unordered lists) nicely indexed, I created a plugin that handles all the form elements for me. After ajax calls that load data into a table or ul, I can just call the plugin on the rows and all forms elements remain in their appropriate order."

Check it out.

Technorati Tags: ,
Posted by PSteele | with no comments
Filed under: ,

MonoRail Contracts

Hammet posted a couple of images he created that showed the main contracts used by MonoRail.  Pretty cool.

Main Contracts

Main Helpers

Technorati Tags: ,,
Posted by PSteele | with no comments
Filed under: ,

Moving up in the GANG

Last Wednesday was election day at GANG.  Our fearless leader for the past three years, John Hopkins, had let us know earlier in the year that he would not be running for president in November.  Instead, he wanted to focus his efforts on sponsorship and publicity for our group.  With the way the economy is, running a group on donations and membership dues alone is difficult.  With John at the helm of our sponsorship efforts, I have no doubt that we'll be in good shape in the upcoming year.

As most vice president's do, I ran for president.  After a lot of campaigning, handshaking and baby kissing, I'm humbled to announce that I was voted president of GANG in a landslide victory.  And to clear the record, there was no campaigning, no handshakes and no baby kissing.  And the fact that I ran un-opposed probably led to my victory.

I'd like to take this opportunity to thank John Hopkins for his leadership the past three years.  He's really taken the group in a great direction and thanks to his efforts, transitioning from vice president to president is going to be pretty easy.  I'm glad he's staying with the group as I know I'll be calling on him for assistance throughout the year.  Thanks John!

And thanks to the rest of the GANG Executive Board that was elected last Wednesday:

Vice President – David Giard (formerly our interim secretary)

Secretary – Kent Fehribach (a new member to our board.  Yeah!)

Treasurer – Jeff Kingery (Jeff has been our treasure for the past two years).

 

Technorati Tags: ,

Posted by PSteele | with no comments
Filed under:

Verifying collections/arrays in MS Unit Testing

If you're using Microsoft's unit testing framework that is built in to VS2008 (and some VS2005 SKU's), you're probably aware of the Assert class.  You use that a lot to make assertions on properties and return values to determine if your unit test passed or failed.

If you try and do an assert on a collection or array (say, an array of doubles), Assert.AreEqual will always return false, even if the contents of the array match.  Example:

   1: [TestMethod]
   2: public void CheckArrays()
   3: {
   4:     double[] array1 = new double[] { 2.0, 3.0, 6.7 };
   5:  
   6:     Assert.AreEqual(new double[] { 2.0, 3.0, 6.7 }, array1);
   7: }

This test results in a failure:

Assert.AreEqual failed. Expected:<System.Double[]>. Actual:<System.Double[]>.

The reason is that with an array, the Assert class is checking for reference equality.  For something simple above you could write three different asserts – one for each element of the array.  But that is too brittle to stand the test of time (or a code review!).  Instead, Microsoft has the CollectionAssert class which will loop through the array and check each element for equality.  If we re-write the test above as:

   1: [TestMethod]
   2: public void CheckArrays()
   3: {
   4:     double[] array1 = new double[] { 2.0, 3.0, 6.7 };
   5:  
   6:     CollectionAssert.AreEqual(new double[] { 2.0, 3.0, 6.7 }, array1);
   7: }

We now get a passing test.

Technorati Tags: ,,
Posted by PSteele | 4 comment(s)
Filed under: ,

MSDN Developer Conference in Detroit

If you missed PDC, now's your chance to catch the best parts of PDC right here in the Detroit area.  From the MSDN Developer Conference website:

We’re bringing the PDC to you! For just $99 you’ll get the best of the PDC in your own backyard and hear all of the exciting announcements around the Azure Services Platform and Windows 7. Other sessions include the latest developments in .NET, Silverlight, Surface, Parallel Programming, Live Mesh, and more.

That's a lot of stuff for only $99 – and it includes food too (breakfast and lunch!).  There's a great lineup of local speakers (Bill Wagner, Jennifer Marsman and Jeff McWherter just to name a few).  Register today and don't miss this local event!

Technorati Tags: ,,,
Posted by PSteele | with no comments
Filed under:

NUnit 2.5 Alpha 4

If you like to live on the leading-edge, check out Dennis Burton's post about the new features in NUnit 2.5 Alpha 4.  Looks like some really nice stuff.  I especially like the improved exception handling with Throws.Exception.

Technorati Tags: ,,
Posted by PSteele | with no comments
Filed under:

ActiveRecord: Never forget there's a database

Some lessons learned while using ActiveRecord.

I really like ActiveRecord and I would recommend using it on .NET projects when there is the need an OR Mapping tool.  The fault lay was us, the developers.  We didn't pay enough attention to the fact that there was a database at the end of the calls that the repository was making.  We didn't spot that some of the calls which our test code was making were potentially very expensive in real usage scenarios.  And so we got bitten by the law of leaky abstractions, which manifest itself through a number of bad usage patterns which caused immediate performance problems.

Read the full post for other lessons.

Technorati tags:
Posted by PSteele | with no comments
Filed under: ,
More Posts