SyntaxHighlighter

Wednesday, 30 June 2010

A note on organisation


Just wanted to mention something I came across last night. I originally had my Utility functions inside a class called AEUtilty.

All of the functions (random number generators etc) were static functions so that I didn't have to have an instance of AEUtility.

Then I came onto creating some simple Timers, which are a class, and I hit a problem. I wanted to group utility functionality together, but obviously nesting the class within the AEUtility class wouldn't be much use.

So I decided to change AEUtility to a namespace, and add a class of AEUtilFunctions to hold the static functions. However intellisense went bonkers, insisting that AEUtility was still a type. So I had to ignore the intellisense and rebuild the library anyway to convince it to behave.

As I'll no doubt be doing plenty of refactoring into namespaces as I go along, I'll have to keep an eye out for this one in the future, as it cost me a good half hour of trying to figure out the problem.

Lesson learnt: just because intellisense says there's an error, doesn't mean the compiler will agree!

No comments:

Post a Comment