Rory Primrose

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

View project on GitHub

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

Is your timer not firing?

I have been developing an RSS aggregator for a while now because I am not happy with any of the apps around. My little project has also meant that I get really good experience developing in VS2005 and SQL2005.

I made a change late last week that the timer used to check for pending feeds was set up to run at the end of a call that loads the user and feed information from the database. The change I made was to have that method run on a different thread so that the UI wasn’t tied up waiting for the database that it may or may not be able to connect to. Today, I am noticing that my timer just isn’t firing.

I was thinking that the only thing that has changed with regard to the timer is that it is now getting initialised and started from a thread that is not the GUI thread. Why should this matter? Perhaps I am showing a little bit of ignorance here, but it shouldn’t matter.

Read More

Unpredictable control rendering is never a good thing

Probably the things I struggle with most in the IT industry (and usually when looking for a new job) revolve around the questions of:

  • How good am I?
  • How much do I know?

These questions are really hard for anyone answer although having a degree and/or other certification helps to indicate what you should know.

Following from these questions, I have often thought about whether I would be good enough to work for this company or that company. Take Microsoft for example. Would I be good enough for them? I don’t know, but I like to think that they are the benchmark for a programmer’s skill as they are a leader in the industry. Every now and then though, I come across some Microsoft code where I can’t really understand why they developed something the way they did. This time, I have come across how checkboxes and radio buttons render themselves in ASP.Net 2.0. I would like to know whether there was some kind of valid design reason for the rendering behavior of these controls or whether it is just, in my humble opinion, poor design.

Read More

Development Tools

These are the development tools that I use. I will skip the obvious applications (which are typically the ones you pay for).

Applications:

  • Reflector - Assembly browser and de-compiler for .NET components
  • NDoc - Creates help documentation from XML comments
  • Dependency Walker - Finds dependencies (great for non .Net app development)
  • Process Explorer - Process management utility
  • Resource Hacker - Great for modifying existing dll resources
  • SQL Scripter - Generates scripts of an existing SQL Server database
  • NSIS - Scriptable installer

Addins:

Sites:

  • PInvoke.Net - Converting API calls to managed methods
Read More

Tricky paging - Learning something new everyday

My team lead sent us an email with a link to http://smh.com.au/articles/2005/11/02/1130823242025.html. He stumbled across a cool bit of functionality when he copied the contents of this five page article. He found that if you select the entire page, copy it to the clipboard then paste it into a program (like notepad), then all five pages of the article are pasted into the document (although this doesn’t seem to work when pasting into Word though).

How does this work?

Firstly, the contents of all five pages are in the source code for each page downloaded. The contents for each page is surrounded in a DIV that has a class and an ID that identifies the page number. There is a script in the page that looks for a querystring that indicates the page number. It loops through each page content DIV and shows or hides it as appropriate. There is a stylesheet reference in the page defined as media=”print” that includes a reference to the css class. This class ensures that when the document is printed, all the page content DIVs are rendered.

So that covers displaying the correct page in the browser, and also printing all pages. What about copying it to the clipboard?

I originally thought that a copy operation was using the media=”print” stylesheet. With a little testing, it seems that this is not the case. A copy seems to ignore the display style and goes off the HTML defined instead. In the case of this page, a copy has the same effect as the media=”print” stylesheet in that all page content DIVs are included.

Whether the copy behavior was understood by the developers or not, it is a very cool side-effect.

Read More