Monday, August 20, 2007

Becoming a Better Developer, part 2

Last month I posted about Justice Gray’s meme of Becoming a Better Developer. I posted what I was going to do in the next six months to become a better developer and challenged four of my friends to do the same. Here’s what they said:

Brian Whittington:

My goal is to “upgrade” my existing skills to take full advantage of the .Net 2.0 Framework. I’m still stuck in the 1.1 Framework mindset, at least to some degree (I’m still using datagrids!). Also, I want to begin using and researching SQL 2005 more so that I am more comfortable using it. I’ve been using SQL 2000 for so long it’s kind of my comfort blanket and I need to move on. Also also, I want to use better OOP techniques in my code. I’ll probably find some good books and go from there.


As for myself and where I am: I’m on chapter 23 (out of 35) of Code Complete. And I’m on the last chapter of Head First Object-Oriented Analysis and Design. My game is coming along as well (though it has been a few weeks since I worked on it.) It now has sound effects.

Friday, August 10, 2007

I just wanted to use a listbox

I just wanted to use a listbox. How hard could that be? Harder than I thought:

I’ve recently decided to try my hand at writing programs for Windows Mobile Smartphones. I had an idea for a program and wanted to see if I could use the Compact Framework 2.0 and get it to work.

One of the main components of my program is a list. So, not surprisingly, I wanted to use a listbox. But it turns out that the version of the Compact Framework for Smartphones doesn’t have a listbox control.

So, I figured: “Oh well, I’ll just have to use a listview control set to List mode.”

(I first met listview controls in VB 6; didn’t like ‘em then and I’m still not too fond of ‘em now. I guess I never cared for the way they handle multicolumn lists – I found subitems to be a pain. But for this project I just needed a single column list.)

Now, in regular .Net a listbox control can hold objects -- as long as the objects implement a .ToString() method. The listbox uses this method to determine what to display in the list. This is exactly what I needed. Unfortunately, listview controls don’t just hold any arbitrary object. Instead they hold listviewitem objects.

So, I tried creating a new object that was derived from a listviewitem object. I planned on adding methods and properties to support my needs. I overrode the .ToString() method and found that listviewitems don’t use .ToString() to determine what text to display in the listview. Instead they have a .Text property. No, problem. I’ll just override the .Text property. Guess what? Listviewitem’s .Text property isn’t overridable!!!

Aaaarrrrrggggghhhhhhh!!!!!!!!!!