sylvain + whissell = geek

From C# to pin sharp (and everything in between).

Good looking code, or fast performing Code? Choose Wisely…

Right around the time that C# 3.0 came out, I was working on a project that required me to count the occurrences of a given character in a string.  This was being done within a highly repetitive loop so it was imperative that it be as efficient as possible.  I’ve always wanted to do performance testing on this and I finally got around to it recently and thought I’d post the results here.

There isn’t anything in the string class that gives us the functionality to count how many times an individual character occurs.  I really hadn’t looked at Lambda expressions and someone at work suggested the following:

    string      testStr = "this,string,has,commas,in,it"            ;
    int         howMany = testStr.ToCharArray().Count(x => x == ',');

I thought, OK, nice and compact (all on one line) but I really didn’t understand it at the time and so went with a brute force way of doing it:

  string      testStr = "this,string,has,commas,in,it";
  int         howMany = 0                             ;
  for (int j = 0; j < testStr.Length; ++j)
  {
      if (testStr[j] == ',')
      {
          ++howMany;
      }
  }

And I’m glad I did.  Here’s why…

Continue reading

Post to LinkedIn Post to Facebook Post to Twitter Post to Delicious

Crap User Interface Design

I don’t get it.  We’ve had big monitors for the better part of 10 years now and resolutions have steadily increased over time.  People, we’re not all running 640 x 480 anymore!  I just bought a Logitech Harmony 700 universal remote.  I love the remote.  Super comfortable, great button layout but their software really isn’t that intuitive to use.  And whoever designed the interface really fell short.

Here’s the screen to customize the buttons on the remote:

image

You can see there’s a scrollbar on the right hand side to show more buttons when you scroll down.  The dialog above doesn’t take up even half my laptop screen so the first thing I did was expand the dialog to fill the height of the screen.  What do you think happened?  Did the controls resize properly?  Oh no…

Continue reading

Post to LinkedIn Post to Facebook Post to Twitter Post to Delicious

Visual Studio 2008 Breakpoints – Writing To The Output Window

One of the things I really love to use when debugging in VS2008 is the ability to have breakpoints write messages to the Output window.  This doesn’t sound like much but there are several advantages to this.  You can have messages printed to the Output window without having to re-compile or add any code.  And you can also have execution continue without stopping on the breakpoint.

So let’s start with the following code (actual text is at the end of this post):

Continue reading

Post to LinkedIn Post to Facebook Post to Twitter Post to Delicious