20/08/2008

Well, that didn't work!

After getting advice, from the beginners' list, about how to create model classes (subclass Object, rather than anything in the collection class, was the general advice), I boldly went forth and tried to build my first app.

It didn't go well!

Actually, I found the whole process both fascinating and frustrating. I started by sketching out - on paper - a class hierarchy, and identifying the properties of each class. Having done that, I then started implementing them in Squeak. As a side note, I am actually beginning to like the Squeak UI! I suspect this is a little like discovering that the mauve kitchen in your new flat is actually quite pleasant, after you get used to it. Actually, that probably isn't fair. I think what is really happening is that I am starting to understand Squeak's tools, and appreciate their usefulness. And, as a result, the very dodgy appearance is fading into the back of my consciousness.

OK, back to the code. I implemented the root class easily enough, and started building the others. However, very soon, I found that I was running around changing the object types used by the various instance variables. This is turn led me to change the method selectors, and that broke the message sends.

What was so fascinating about all this was that I was managing to confuse myself when I only had 4 classes!

Having had a chance to think about this - and ask for advice on the list - I have realised some of my mistakes:

  1. I identified object properties whereas I should have thought about methods - in other words what did I need the objects to do.
  2. I didn't create use cases. I know it seems crazy to do that for such a simple system, but as my experience shows, it is very easy to get it wrong.
  3. I should have written the tests first - yes, I know, that's what the book says, I just wanted to get on with building things :-)


So, let's have another go.

No comments: