Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

Code conversion pitfalls

After doing four days of training and meetings in Brisbane, I am now back in the office reviewing some code. I had originally developed some web custom controls in VB (the organisations language of choice) that were then put into an architecture framework. This required that the code be converted from VB to C# which is the language of the framework involved. This work was done by another person while I was back in my prior UI design team.

Doing a code review of C# that is based on my VB code has put me in a new situation. Not having done this before, I am trying to think of scenarios that look safe, but are trouble under the surface. Turns out I found one very quickly. In this case, string comparisons are the danger. The VB code often had statements like this:

Read More

Update to Geoff's enum to string converter

When I get some spare time here and there, I am developing a template driven code generator which uses a database schema as a data source. In doing this, I want the templates to specify what type their output is. To support this, I have defined an enum TemplateTypes with the values of TSQL, VisualBasic, CSharp and Unknown. I want to be able to convert the names of the enum values to more friendly values so I can use them in things like the tooltip text of nodes in a treeview. I remembered that Geoff had previously posted about using type converters with enums to achieve this.

To avoid reinventing the wheel, I took his code and ran. What I found though, is that when the enum value name is converted to a nice string, it adds a space each time that it encountered an uppercase character that wasn’t the first character in the name. This means that TSQL was converted to T S Q L. I made minor changes to his EnumToString function so that it only adds a space when it finds that the previous character is lowercase. I also added a conversion of _ to spaces as well.

The function now looks like this:

Read More

WebBrowser.DocumentText doesn't always update the browser contents

I have been developing some new software which uses the WebBrowser control. Depending on what is selected in a TreeView control, the browser will be instructed to load some HTML that has been created and manipulated in memory.

The problem I have encountered is that once the HTML has been determined, setting the DocumentText property hasn’t been updating what is displayed in the browser. It only displays the HTML that was orginally assigned to the control. The reason for this not working is hinted at in the help documentation for the Document Text property. The documentation says this:

Use this property when you want to manipulate the contents of an HTML page displayed in the WebBrowser control using string processing tools. You can use this property, for example, to load pages from a database or to analyze pages using regular expressions. When you set this property, the WebBrowser control automatically navigates to the about:blank URL before loading the specified text. This means that the Navigating, Navigated, and DocumentCompleted events occur when you set this property, and the value of the Url property is no longer meaningful.

Read More

How important is UI design for software?

I have been thinking about this question ever since I started my first ‘real’ job in the industry when I was half way through university. Each time I think about UI design and what it means to software, I come to the same conclusion.

Market acceptance and widespread use of software is now becoming proportionate to the quality of the UI design of that software.

Traditionally, UI design wasn’t seen as important as functionality, regardless of what the user liked to see. UI design was seen as an unnecessary project expense. There didn’t seem to be a link made between UI design and usability. I believe that design and usability go hand in hand and usability will always impact on the functionality of software or at least the users willingness and ability to use the functionality provided. Unfortunately, this still seems to be the case in many software projects today.

Robert Scoble recently had an interview with Jenny Lam, a designer on the Microsoft User Experience team. It was very interesting to hear about the progress Microsoft and the rest of the industry has made with regard to UI design. As it should, UI design is now starting to become more important in the overall software design process. Although I am a developer, my current role is in a UI design team and I also see many of the struggles in trying to get UI design recognised as important to a product.

Read More

That beginners feeling - Episode 23

Like most things in life, if you haven’t needed to do a particular task before, then you probably don’t know a lot about it, let alone how to actually do the task.

Today, I felt like a novice programmer. Something very simple, but also simply misunderstood, was causing me grief. The issue was caused by multi-dimensional arrays. I simply haven’t had a need for multi-dimensional arrays, probably since uni. To me, multi-dimensional arrays are about relationships between data and that normally screams databases to me, not arrays.

Each time I need to loop though an array, I will loop while the index is less than MyArray.Length. Until today, this has always been fine. Now I have a multi-dimensional array, Length is returning a much larger number than I expected. I initially thought that the Length property was returning the length of the first dimension x the number of dimensions. I thought this because I had a [24, 2] array declaration and Length was returning 48. Logical conclusion right?

Read More

Green it was

For several months at the end of last year, Canberra has received more rain than we have probably seen for years. The whole area has been brown due to a lengthy drought for many years. While most of the surrounding state is still drought declared, Canberra has been able to make something of the rain it has been given.

Unfortunately, Canberra is all brown again. Pity, it was quite beautiful when everything was green.

Read More

Switching teams

I’ll let you in on a little secret of mine. I quietly enjoy the VB vs. C# language flame wars.

Mostly I think it is a bit ridiculous how passionately and personally people take this ‘mine is better than yours’ argument. As I don’t take it as a personal argument, I think most peoples behavior in this arena is a lot like a comedy sitcom. You watch it, laugh at it and then change channels.

I have enjoyed working and playing with VB since 1998 (about 1990 if you include a little dabbling in GW Basic). I find VB really easy to read and very forgiving for a typist that doesn’t have 100% typing accuracy. Having been often restricted by VB5 and VB6 capabilities compared to C++, I have really enjoyed the advances made in VB.Net.

That being said, as much as I enjoy VB, I have now started to spread my wings into C#. I have been able to follow C# without a problem, but haven’t really spent any solid time developing in it. I see this as a disadvantage and probably a hindrance to my career. There is really not much difference between the two, but being fluent in both is a definite advantage.

Now it’s out there, all you C# junkies can enjoy this small win in your flame war.

Mitch, stop smiling.

Geoff, stop crying.

Bill, put down that hammer.

Read More

Product design is an art form

I don’t think that I am very easy to please when it comes to products and customer service. It generally takes a lot for me to experience the ‘wow’ factor.

From a product point of view, the things that I like tend to be really complex (like computers) or look really cool (like a really sweet GUI design or website). I think that what this comes down to is that consumers are expecting more bang for their buck as technology has progressed. As for customer service, I think the ‘wow’ factor usually can’t be found. This isn’t always the case, but customer service is seriously flawed in today’s commercial world.

Every now and then though, I really get a kick out of simple designs. Take this for example. What a fantastic, yet very simple idea. For me, I think this product is up there with the loop design on power cable plugs so you can loop your finger through the plug rather than pulling on the cord.

Waiting for the next ‘wow’…

Read More