Thursday, June 17, 2004

Coupla interesting links

I don't usually post links on their own. It's not a conscious thing, it's just that normally when I blog it's not because I've found something interesting online, normally it's just because I've done something that (I at any rate) find a bit interesting, or overcome a bit of a problem.

However, I've found a couple of really quite nice blogs in my miscellaneous wanderings.

  • Sikko2Go seems at a glance to be in a similar boat to me, certainly in terms of .NET development. Bit of a newbie, but he's got some interesting things to say about some of his experiences.
  • Cathi Gero has probably forgotten more about data widgetry than I will ever know. She's posted some really quite cool tips and tricks when working with ADO.NET.
That is all.
PS - Just found something that made me chuckle - Blogger.com's spelling checker doesn't include the word 'blog'.

Wednesday, June 16, 2004

Typical Benjimawoo...

As usual, I'm having trouble at the vey first stage of writing my little face recogniser. I do this every time. I've got stuff written in my head for parsing and identifying face elements fine. Not a problem. I can take a character map (if that's what it's called) and split it down into individual faces, and further down into individual elements (Noses etc.)

What I can't figure out how to do (at the moment) is convert the file from a text file to a bitmap. I've had many thoughts on he best way to do this, but they all seem not only a bit long-winded, but also a bit overcomplicated.

I'll keep thinking...

Monday, June 14, 2004

My Next Project

Inspired by this sample problem from an IPSC programming competition, I'm going to write an app that solves it.

Hopefully (just thinking the problem through over a cigarette) I'll be able to create something quite flexible. The published solutions depend on a certain degree of manual checking, and comparing. The 'best' solution published iterated through each type of face, and essentially produced a count of each type, as well as a graphical representation (I think). The user could then go through and add together the numbers of smiling faces. Fine.

Not my style, though. I think I'll have a go at writing something more fully automated. I'm thinking it'll work something like this:

  • Takes a file as input ( as published)
  • Some sort of algorithm parses the file into regions of faces (One of the knowns is that faces are all bounded by a continuous line)
  • Each face is rendered graphically (i.e using GDI+ to draw lines to join the dots)
Once each face is rendered as a set of graphics elements, the noise can hopefully be filtered out (some of the faces have wrinkles etc.). Once the face has been broken down into its key parts (Eyes, Nose & Mouth) then it'll be a simple(ish) task to pick out the mouth and determine whether or not it's smiling.

Should be fun. I've got a rough idea of how it'll work, and it'll give me an excuse to use a bit of GDI. Never used it before!

"Using" Statement in Whidbey

I just read here that the 'using' statement is going to be implemented in the next version of VB.NET.

I also read somewhere else that 'Using' is a really useful statement, and something that's been missing from VB for years (Apparently it's been about in the C variations for ages). What it does is this:

"The using statement obtains one or more resources, executes a statement, and then disposes of the resource."
This makes it pretty mich equivalent (apparently) to using a try..Catch..Finally block to ensure that Dispose() is called for any resources that implement it.

It might just be the example they chose, or it might just be me, but I can't see a huge amount of use for it - Using (pardon the pun) 'Using' ensures that resources are freed up when they're out of scope, but it doesn't have the error handling capability that a try..Catch..Finally has. If everything works fine, then that's OK, but if it doesn't, then the app'll fall over.

One rule of thumb I read (can't remember where, but it makes sense to me) is that every time you use a resource external to your app (Disk Files, Databases etc...) then that should all be wrapped in an error handling block. Kind of negates the need for 'Using' in my view...

Although having said that, I suppose it depends to a certain extent it depends how many resources you're using, and when the CLR actually disposes of them. Picture the scene:
Public Sub Go()
Try
Using sw As StreamWriter = New StreamWriter("C:\hey.txt")
sw.Write("HEY")
End Using
Catch ex as Exception
'Handle ex, notify user etc.
Finally
'Does anything need to go here?
End Try
End Sub
If the line sw.write("Hey") throws an exception, the execution steps out of the Using block and into the Catch block. Does the CLR dispose of sw at that point, or does it need a call to sw.Dispose in the finally section? Does it really add that much benefit? If it frees up resources regardless or not of whether the code within the Using block throws an exception or not, then it'll make the code more readable and certainly shorter, allowing you to do away with the Finally block altogether, but there are few examples that I can think of at the top of my head where this would be particularly desirable over a normal Try..Catch..Finally block.

I'm sure there are times when resources need to be disposed of, and yes, 'Using' does handle that for you, but in my (Ok, limited) experience, it doesn't seem to make a huge impact on the language. I'm sure that'll all change though, when I start 'Using' it (Boom Boom!).

Just a thought. Don't horsewhip me for being ungracious...

Thursday, June 10, 2004

Another project...

Hmmm. Time for another project. Since ASP2WMP seems to be working fine (Although I still haven't got my sexy phone yet, so can't really try it in real life. Darned stock shortages!) I think I need to move on to something else.

But what, though? In my quest for knowledge (I'm determined to get certified, even if it kills me!) I find it difficult to do another project similar to what I've done before - Half the reason I'm doing them at all is to get experience using a wider range of technologies that .NET has to offer. Doing the same thing over seems a bit naff.

At the same time, though, I'm too lazy to do something I see no practical use for. ASP2WMP came from a bit of lazyness, a bit of an article I read, and a bit of wanting to do something new (Remoting, Services etc..). MediaTagger (a little batch importing tool I wrote for adding MP3's to my Media Library was borne from wanting to add loads of files to my Media Library. What next, though? Hmmm. Tricky. I thnk I'll have to have a bit of a think on that one. I'll keep you posted...

Wednesday, June 09, 2004

Bah.

Got turned down for a job today. Got I hate interviews.This made me laugh, though.

So that's alright.

Wednesday, June 02, 2004

vbasic @ the movies

All hail msdn. The 101 Visual Basic Movies have been put online to download locally. A lifesaver for the likes of me with my dodgy intermittent 56k connection. Bah. Time for Broadband. Still takes an hour for each batch, though.

Either way, I've just spent the past 2 hours watching them. Fantastic, particularly if, like me, you have no coder friends and just learn everything from books.

Just wanted to share. Although the link came from Mike Gunderloy's site.

Tuesday, June 01, 2004

Sorted... ish!

Well I managed to get my ASP2WMP service running properly. One thing nobody ever told me, however, was that blank passwords aren't allowed for a few interesting things. Yes, yes, yes, I know it's needed for security, and yes, I know it would be computer doom, but a littel warning would have been nice.

Until today my account wasn't password protected. I didn't reckon I needed it to get onto my computer at home. I trust myself and I trust Mrs Mawoo not to do anything nasty. However, when I tried to install the service, it would either prompt me for a password if I set it like this:

Me.ServiceProcessInstaller1.Password = nothing
Me.ServiceProcessInstaller1.Username = "COMPUTER\Ben"
and kick out an error during installation, just saying that the password was wrong, or when put in like this:
Me.ServiceProcessInstaller1.Password = "
Me.ServiceProcessInstaller1.Username = "COMPUTER\Ben"
it installed fine, but then I couldn't start the service. It said there was a logon problem.

It was only through finding an app, selecting 'Run As...' and trying to run it as a different account that it helpfully told me that I couldn't do things like that with non-password protected accounts. Aha!

Created a password, installed the service using that password (yes, I know I could have done it through MMC, but I daresay I'm going to be reinstalling it some point) and now it works like a beauty. So when I get my sexy new phone, I can navigate through my music etc. from that without even logging in. Cool eh?

Still means I have to type in my password every time I log in, though, which s a bit of a pain. One day I might look at creating a user account that works with it, but isn't mine. I'll leave that until another day, though.

Aha! And erm...

Back from sunny Plymouth yesterday. I might even get some pics up shortly.

I did, however, find this post that answers all the questions I've been trying to find answers to re. developing applications for devices on the cheap.

I need to do some more researching as well on running Windows Services on a different acount, or at least try to find out more about WMP's media library. The ASP2WMP remoting object works fine and dandy if I run it as a console app. That's great for development and testing, and also gives me a chance to use it now and again (just to feel all warm inside!) but now I want to develop it a bit further so I don't have to run that app.

I guess there are several ways I could do it. I could look at running the service as me, thus (hopefully) getting access to my version of WMP's media library. I could see about setting up the shared media player object so it specifies a library to check out. I could even look at an alternative to listing and selecting tracks from WMP's in-built Media Library. Hmmm. Much to think about.

And I've got to go to Plymouth again next weekend too!

Thursday, May 27, 2004

TDD for amateurs...

I do like Test Driven Development. I really do. I can see how it (along with the other aspects of agile programming, eXtreme programming and the like. I can see how it can create quite a clear focus, expected outcome --> test --> code to pass the test. It sounds great.

I really can't get myself motivated to do it, though. The problem with being a hobbyist developer is that you never have a properly specced project. It's always something focused on what you know/what you're interested in/what you want to do. Because there's no 'client' to satisfy, you end up with a very organic development process. There's rarely a clear outcome at the beginning, and so, you can't write the tests to produce that outcome. Now I guess you could argue that if you're ultra disciplined or ultra skilled, then that doesn't matter. You can write your code, and you'll be able to make sure it fits nicely and all the rest. If you're not, though, it can be a it frustrating.

Not too bad, though. I've discovered that there are very few coding mistakes that can't be brushed under the carpet with an inherited class.

Test Driven is really good, though. The few times I've managed to keep myself disciplined enough to write the tests and develop from there have been really good fun. I'm focused, and there are a whole load of really quick wins. Which is nice.

I guess I really should start writing the tests and coding around them again. Of all the things I miss, NUnit's big green bar really does fill me with joy!