Monthly Archives: October 2008

Backup Plan!

Spotted at my local bus stop…

 

OpenID

So, recently I went and had a look at stackoverflow.com, and decided to register. And got presented with the whole OpenID fiasco…

Thankfully the creators of the site that runs this blog are OpenID suppliers and thus I had a ready made ID. So I’m good to go.

Then I read that the BBC had hosted a meeting of the OpenID foundation after having joined a year ago. The article goes over the main bugbears I also have with the OpenID experience (quoted directly):

  • First, you can be redirected from one website (the one accepting the identifier) to a different domain (that of the provider) and then returned to the first. This is confusing for an average user, especially if different wording, layout and styles are used. The attribute exchange part of the OpenID protocol works: it’s a good idea to exchange the registration parameters and to simplify steps at the receiving site. However, if implemented badly (or not implemented at all), it adds even more confusion to the journey. The confusion also adds a weak point where scammers and phishers can jump in.
  • Second, all users are familiar with the username and password as the login paradigm. Suddenly using URLs, like http://openid.foo.bar/john/smith, may be difficult for a mainstream user to understand.
    (However, the so-called “Generation @”, which uses instant messaging and social spaces as well as traditional email, is aging, and so the main audience segments will be people used to representing themselves with the URL of a blog, MySpace profile or Flickr account).

Now apart from the parallel the process seems to have with the Credit Card processes (Visa’s “Verified by Visa” and Mastercard’s Securecode) which is in itself a little scary, the main gripe for me is that OpenID is using a token which is at least one step removed from me.

The assumption is that each one of us has a unqiue URL, which you might argue could work if we are all signed up to MySpace, Facebook and so on. But those are social network sites, which by definition do not represent the individuals, so those URLs are out.

Ok, what about that vanity domain you have…

…well so long as you are the only one that has it, and that it matches an OpenID system somewhere and you don’t let it expire…

No. Frankly the one constant we can cope with is that email is the common denominator and that the user scheme for that is very well defined down to an individual. The idea of ” person@place ” has been around for a long time and been refined. If you have an Office PC the chances are you use the same thing, albeit reformatted slightly as: ” \\place\person “, or even ” user@host ” or some other set of synonyms.

The difference between these and the URL, is that the URL is a presentation of your data at an application level, not a user credential for access, it is an index to find your stuff, not “you”. Never mind that a URL is often a symbolic link to information, rather then the actual information, which is all good for information hiding.

There has already been some work done on the usability of the URI vs EMail and  OpenID authentication process, which makes an interesting read and ends up with the idea of suggesting possible Ids based on emails. The inconsistency of the flow does worry me, in a world where most websites have become farily sensible about logins, this is just an extra barrier. The oft understated part is also that the OpenID provider is the party that vouches for you. The thing is, I might trust you, but not your provider, and I’m fairly certain my bank – amongst others – will not trust either of you. So while this is supposedly making it easier for me to login into to many places, it does so at a level that suggests that my reputation is now based on the “trustworthyness” of my login provider, rather then “me”.

I’ll be sticking to my person@place for now.

Really…

The BBC has got a front page today proclaiming that Dubai isn’t all it seems to be… which is nothing to do with two people being sentenced for breaking the law.

image

Given all the great reporting that we’ve had from the Middle East, this lets the side down a bit as it implied Auntie is catching up again.

Using nUnit 2.4.3 with VS 2005

I’ve been having a look at unit testing with C# recently, since I was going to try coding some stuff in C# I thought I might as well start with some good TDD practices. Along the way I found some inconsistencies, and some ideas, so I thought I’d share them here.

So first up, got my starting materials, for this exercise I was using:

  • Visual Studio 2005 – no plugins or 3rd party kit, just the MSDN professional edition version.
  • nUnit 2.4.3 – I got this from SourceForge as an MSI, the homepage is here if you’re after a different variant.

In theory the instructions should work for the VS Express editions, but I haven’t tried them, if you have, please add a comment below to share your experience.

Make a Start

I’m going to assume you’ve installed Visual Studio (VS), if not then the DVD and the MSDN website have a load of useful info on that.

To install nUnit I followed the instructions from their homepage, upto the point where you run the tests that come with the installation. So for the rest of this it is assumed you’ve got the Gui working with the nice green bar that implies your nUnit install is all in the right place (usually C:\Program Files\nUnit 2.4.3\ if you pick the defaults). It is worth having the nUnit tutorial open in a browser, this is usually installed as a menu item on the Start Menu (C:\Program Files\NUnit 2.4.3\doc\quickStart.html if you’ve used the defaults).

A new Solution…

Before this point the only IDE I’d used in much anger was Eclipse, which I quite like, although I’m still one of those people who likes fiddling with the makefiles. Now from that point of view, a Project is the thing you’re building.

Well not quite in VS, a Project is a sub-set of a “Solution”, and a Solution can have many Projects. A Project may also be shared amongst many Solutions.

So with this in mind, I came up with a method to separate my test code from my “real” code, so that when I release it, I’m not bundling all the unit tests with it.

Real Project vs Test Project

At the moment I’m creating an Assembly (DLL), and as a test I’ve put a Calculate class in it.

The real code is in: democode.Calculate and the test code is in: test.democode.TestCalculate.

The democode namespace is in the “Real” project, and the test.democode namespace is in the “Test” project.

In the Real Project, you need to create your democode.Calculate class:

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Text; 
   4:  
   5: namespace democode
   6: {
   7:     public class Calculate
   8:     {
   9:         /*
  10:          * Add two numbers
  11:          */
  12:         public int add(int a, int b)
  13:         {
  14:             return a + b;
  15:         } 
  16:  
  17:         /*
  18:          * Subtraction 
  19:          */
  20:         public int subtract(int a, int b)
  21:         {
  22:             return a - b;
  23:         }
  24:     }
  25: }
  26:  

In the Test Project,  you need to add a Reference to the nunit.framework by right clicking on the References section for that Project and going through the “Add Reference” dialog. Then we can add a test:

   1: using System;
   2: using System.Collections.Generic;
   3: using System.Text;
   4: using NUnit.Framework;
   5: using democode; 
   6:  
   7: namespace test.democode
   8: {
   9:     [TestFixture]
  10:     public class TestCalculate
  11:     {
  12:         [Test]
  13:         public void testAdd()
  14:         {
  15:             Calculate c = new Calculate();
  16:             Assert.AreEqual(4, c.add(2, 2));
  17:         } 
  18:  
  19:         [Test]
  20:         public void testSubtract1()
  21:         {
  22:             Calculate c = new Calculate();
  23:             Assert.AreEqual(2, c.subtract(4, 2));
  24:         } 
  25:  
  26:         [Test]
  27:         public void testSubtract2()
  28:         {
  29:             Calculate c = new Calculate();
  30:             Assert.AreEqual(-2, c.subtract(2, 4));
  31:         }
  32:     }
  33: }
  34:  

For an explanation of the code and guidance I followed the tutorial, however there are a couple of inconsistencies, the library suggests using the Assert class with the static methods, rather then “AssertEquals”.

Run the Tests!

Now at this point it has to be said I missed the relative simplicity of the jUnit test framework in eclipse which has integrated the Gui into the IDE to give you a quick way of switching between the tests and the code and also running the tests with the famous “Green Bar”.

For NUnit I found this a bit more difficult, the configuration defeated me somewhat, so I’ve opted for (hopefully) a simpler solution:

Under the Visual Studio “Tools” menu, click on “External Tools…”, when the dialog pops up, hit “Add”. Then add a new option of the NUnit Gui and fill out the arguments to point to the nunit exe and the Project Directory and the Project Filename (the .cproj file) using the Visual Studio variables. See example below:

Visual Studio External Tools dialog

Note that this works only if you have ticked the Visual Studio support option in the NUnit menu under Tools -> Options…, as below:

NUnit Options dialog

Now, in the Visual Studio IDE, whenever you want to run the tests for your project, simply go to the Tools Menu and Select NUnit Gui, and hit “Run”.

Addendum

Proof that you should document these things, having done this and forgotten about it, I had need of it again recently, and being able to just use the menu option made life a lot easier. While I’m at it, much kudos to Leo Vildosola for his Code Snippet Plugin, without which the code would look pretty bad, it also means I don’t have to make good on my previous post as frankly his work is a lot better.

Regular Expressions in .Net

I’ve been getting around to doing some C# coding (!!!!!) recently and wanted to use some regular expressions to match some parts of strings (yeah, yeah, now I have two problems :-P). Someone pointed me at Rad Software Regular Expression Designer, which helps to visualise and construct regular expressions for .Net. Unfortunately when I modified the layout, I found that moving certain windows meant I couldn’t place the windows where I wanted (I managed to remove three of the columns and couldn’t recreate them :().

Aargh.

So after faffing around, I found that the configuration file written out by the Magic UI components is put in and XML which lives in:

%APPDATA%\Rad.RegexDesigner

Stop the app, delete the file and then restart the application and the layout is back to how it was.

Running to stay in the same place

Just managed to catch up on Chris’ blog, and phew that’s a lot of writing, but then that’s a lot of life!

I’ve got a lot of sympathy for the job situation, I think it’s a matter of some public record that things are not all that great where I’m working and that’s down to the lack of clarity amongst other things. But before I land myself in the proverbial soup…

Today was a break from that and to go have a look around Kingston. The verdict is… “meh”. Sorry, you have the river, and some nice shops, but we will be getting our own version of Paul soon, so we might leave that one 🙂

Actually while I’m at it, big mention for a new culinary find in London, which turns out to be around the corner from my Chinese Class. The restaurant: Ten Ten Tei on Brewer street turns out to be a good choice for those wanting a decent Japanese meal without taking out a mortgage.

Ok, now time to tango with the Immigration authorities. Ok guys, Bring it!

Currently Listening to: The Corrs – Borrowed Heaven