Tuesday, November 11, 2008

How to not do validation

Yesterday when I was trying to do some online shopping I the e-commerce system in use perfomed input validation in a slightly suboptimal way. Here is what happened:

  • To be able check out the stuff in my shopping basket I had to create an account.
  • To create an account I had to enter username, password and address.
  • Go to checkout
  • Confirm to use the just entered address as the shipping address
  • On the following page where the pay button should be there's this small note "The city is not long enough"  WTF!?!
  • Try again with the city name in the other language as it is longer
  • Same story "The city is not long enough" ...
  • Only when changing the primary address the order goes through

A validation rule stating that the city cannot be just three letters are just plain stupid, secondly if there is a need to use stupid validation rules, then do the validation when the data is entered and not when it is used ...

This comic comes to mind.

Saturday, November 08, 2008

Debugging WPF databinding issues

Lately due to switching teams and project I've been doing much more WPF than before. I cannot say I have fully mastered the learning curve yet but I'm getting better and it is an interesting journey.

Occasionally the data bindings does not work as expected and then it is nice to get more information about them in order to figure out what went wrong.

The following is useful when you want to know why a particular binding is misbehaving (or rather you want to know where you screwed up...)

xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"



ItemsSource="{Binding <snip>, diagnostics:PresentationTraceSources.TraceLevel=High}"


The above information and MUCH more is presented by Beatriz Stollnitz



(This post is also a 'reminder to self')

Monday, November 03, 2008

C# quiz 9/?

Consider the following:

Guid globallyUnique1 = new Guid();
Guid globallyUnique2 = new Guid();
if (globallyUnique1 == globallyUnique2)
{
MessageBox.Show("This cannot be");
}
else
{
MessageBox.Show("Everything is well");
}

What is shown? Why?