'Geek' Archive

DemoCampGuelph2 this week

July 16th, 2007

Just a reminder to anyone paying attention, our second democamp runs this Wednesday evening. If you’re coming out, please add your name to the attendee list on the wiki.

Just a reminder, this isn’t a BarCamp where everyone must participate so come out, have a beer and a 1/2 priced burger and just lurk. There are a few demo spots left so contact me if you’d like to demo.

Batteries

July 2nd, 2007

I finally got around to buying a small UPS. It’s silly how reasonable the prices are now. This Belkin 900VA was $86 at tiger direct. I think I’m getting old because I find myself having to resist the urge to say “I remember when simple power bars were $60”.

These are heavy so the shipping costs were a tad high. I did a quick compare to see it picking one up at staples would be cheaper. Unless I’m missing something, the exact product is $176 at staples. In that light, shipping was quite reasonable.

Why am I posting crap about batteries……sad times…How could this get any more sad? There, a picture of said battery….

IDig IComparable

June 27th, 2007

(Apologies for the code samples, indenting and justification is hosed so it ain’t pretty. I’ll fix that someday when all I have to do in a day is tinker with websites.)

Anytime I contemplate doing any of the following to a custom class: sorting, overriding Equals, overriding GetHashCode, or building typed collections, I typically start with IComparable. That is, I start by having the class implement IComparable.

Let’s say you’ve got a User class and it’s uniqueness is measured by it’s primary key in the database, represented by it’s Index property. I typically start by overriding GetHashCode(), so in this case you’d have:

public override int GetHashCode()
{
return this.Index;
}

The rules are that if GetHashCode is identical for two objects then they’re equal. So implementing IComparable is just a matter or relying on your GetHashCode:

public int CompareTo(object obj)
{
if (!(obj is User))
{
throw new ArgumentException();
}
User user2 = (User)obj;
int compare1 = this.GetHashCode().CompareTo(user2.GetHashCode());
return compare1;
}

Now that you’ve got a working CompareTo, you can use it for your Equals:

public override bool Equals(object obj)
{
if (this.CompareTo(obj) == 0)
{
return true;
}
return false;
}

If you asked me, that’s a clean, quick and simple way to have your objects support comparisons, hashing, and sorting using IComparable. As well, if you need a custom, strongly typed collection for you object then you can use CompareTo for comparison methods such as Contains, BinarySearch, etc.

Obviously this won’t handle every class and things will get more complicated but it takes care of the majority of cases and gets a strong foundation in place.

Sorting with IComparable Links

Desktops and cheap parts

June 20th, 2007

Some may remember my recent switch back to a desktop. The idea being that it’d be significantly cheaper to build my dream desktop than get a new laptop. I’d then run vmware, sshd, etc allowing me to work on that desktop remotely.

That means when I’m doing tasks like compiling in visual studio, I’m actually building on my burly new machine instead of my sad old laptop. Another big reason for the switch was to have access to cheap parts and easy hardware upgrades. I haven’t taken advantage of that until last night.

I bought, and installed, 2 x 1GB of RAM for $79. I now have 4 GB of RAM total. I feel like I’m cheating.

DemoCampGuelph pics

June 8th, 2007

So that’s what a DemoCamp in Guelph looks like.

#2 is in the works, it’ll be sometime mid July, sign up! Get on our google group as well.

DemoCampGuelph1

June 6th, 2007

Last call for DemoCampGuelph1. Tonight, Albion, second floor, 6:30 to 8:30pm.

Hopefully it’s not just bubba and I having pints….

Microsoft changes it’s ApplicationException stance

May 11th, 2007

It’s been a while since exceptions cropped up here. While this isn’t ‘hot off the presses’, I’m certainly just catching up. When the boys at Microsoft originally built the .NET framework, they added a base exception class named ApplicationException. They suggested, and illustrated themselves in any related example they wrote, that custom exceptions in your application should extend from this instead of the base Exception:

“User applications, not the common language runtime, throw custom exceptions derived from the ApplicationException class. The ApplicationException class differentiates between exceptions defined by applications versus exceptions defined by the system.”

If you read past that paragraph then you’ll discover that this class is essentially a dead class now:

“If you are designing an application that needs to create its own exceptions, you are advised to derive custom exceptions from the Exception class. It was originally thought that custom exceptions should derive from the ApplicationException class; however in practice this has not been found to add significant value.”

Of course they don’t go out of their way to explain why there isn’t “significant value”, however, Brad Abrams does here. Actually the explanation is in the post comments:

“When first reading Mr. Richters advice on not using ApplicationException I was stunned, but it actually make sense. If you create some application specific exceptions you may want to derive these exceptions from a common base class in order to be able to catch them all in a single catch clause. Deriving this common exception from ApplicationException doesn’t add anything useful to your exception hierarchy – it just deepens it.”

Basically MS deepened the exception hierarchy without adding ANY value which is rule #something of designing quality custom exceptions:

“Designing exception hierarchies is tricky. Well-designed exception hierarchies are wide, not very deep, and contain only those exceptions for which there is a programmatic scenario for catching. We added ApplicationException thinking it would add value by grouping exceptions declared outside of the .NET Framework, but there is no scenario for catching ApplicationException and it only adds unnecessary depth to the hierarchy. You should not define new exception classes derived from ApplicationException; use Exception instead. In addition, you should not write code that catches ApplicationException.”

DemoCampGuelph

April 27th, 2007

I’m taking a shot at organizing DemoCampGuelph1. What’s a DemoCamp?

“A DemoCamp is a lighter-weight style of un-conference. A DemoCamp last only a few hours on a weekday evening, as opposed to a traditional BarCamp which would usually be a multi-day event and take place on a weekend. As such, they are easier to organize and tend to happen more frequently.”

It’s pretty simple. It’s about going to the albion, having some good grease and pints and mingling with other people who work in technology who live in Guelph and surrounding areas. That’s it. It really isn’t difficult.

If this is going to happen then we need to drum up attendees and presenters. Presentations are short (5 minutes) and don’t have to be earth shattering. You don’t have to demo something you’ve built or had anything to do with. It could just be some piece of technology you feel is worth sharing. That’s it. See demo tips on the DemoCamp page.

Go to the DemoCampGuelph1 page and sign up. Go to the GuelphCamp page and sign up for the groups.

Yubnub.org

April 25th, 2007

Jaimie sent me this today. I really like the concept but I’ve been using the firefox search of late and couldn’t see myself going back to using a website to kick off search. I took a second look tonight and sure enough a search plugin does exist so I’m on board with the yubnub.

My question is, why isn’t this part of the search tool in Firefox so that I can configure and customize it? Or maybe allow me to set a keyword for each search engine I install so that I can select the search engine using the first word I type instead of having to use the mouse and dropdown.

I used to use %s and keywords in bookmarks to hack something similar in the address bar. I should take a peek, maybe an extension already exists for this.

Accurate Software Estimates

April 23rd, 2007

Nothing much more than agreement and a link.