Look who’s on the JBehave team!

http://jbehave.codehaus.org/team.html

I guess this means I can officially answer questions etc. now.

Most recently, I’ve got JBehave to help me with the design of my Gui functionality. I did this by making a “ComponentFixtureDelegate” class, extending Abbot’s ComponentFixture. I used subclasses of this for each panel or frame in my behaviour class. I guess you could always extend ComponentFixture and delegate UsingMiniMock instead, but most importantly, it can be done. The panel and frame fixture extensions will also be useful for the story-running.

This is good, since it means that I can now start running stories without any mocks in at all.

My next step will involve changing JBehave so that it can run multiple events. Dan’s idea is to use “Steps”; event / outcome pairs which can be added in sequence. In my Tetris-like game “Hellbound”, this will enable me to easily do things like “move shape right, move shape right, rotate shape anticlockwise, rotate shape anticlockwise, drop shape”, expecting certain outcomes at each point.

Of course, I don’t need to feed these events into the game engine any more… I will be able to actually make the fixtures click on the relevant buttons or press the relevant keys.

At some point I may also get around to writing a couple of tutorials, and maybe making Hellbound open-source so that you can see an example of a real project using JBehave.

Posted in Uncategorized | Leave a comment

Look who's on the JBehave team!

http://jbehave.codehaus.org/team.html

I guess this means I can officially answer questions etc. now.

Most recently, I’ve got JBehave to help me with the design of my Gui functionality. I did this by making a “ComponentFixtureDelegate” class, extending Abbot’s ComponentFixture. I used subclasses of this for each panel or frame in my behaviour class. I guess you could always extend ComponentFixture and delegate UsingMiniMock instead, but most importantly, it can be done. The panel and frame fixture extensions will also be useful for the story-running.

This is good, since it means that I can now start running stories without any mocks in at all.

My next step will involve changing JBehave so that it can run multiple events. Dan’s idea is to use “Steps”; event / outcome pairs which can be added in sequence. In my Tetris-like game “Hellbound”, this will enable me to easily do things like “move shape right, move shape right, rotate shape anticlockwise, rotate shape anticlockwise, drop shape”, expecting certain outcomes at each point.

Of course, I don’t need to feed these events into the game engine any more… I will be able to actually make the fixtures click on the relevant buttons or press the relevant keys.

At some point I may also get around to writing a couple of tutorials, and maybe making Hellbound open-source so that you can see an example of a real project using JBehave.

Posted in Uncategorized | Leave a comment

Do androids dream of electric solicitors?

If you did get an AI which could convert using pattern-matching between two arbitrary formats, given samples of, eg: songs, in each format… does it still count as “reverse engineering” of any proprietary formats that happen to get passed to it?

Even if the AI is the thing being sold, not the actual conversion algorithm, and there’s no law being broken when it’s converting between open standards?

And who would you sue? The developers of the AI, the person who used the AI to do the reverse engineering or the AI itself?

It’s only theoretical, I know, but all things may come to pass…

“How to resolve difficult court cases:
Create an AI with n randomly-generated conflicting artificial personalities which will interact to arrive at a verdict. n should be a sufficiently high number for a reasonable chance of a fair trial, eg: 12.”

In other random thoughts, I find it amusing that Apple has asked XTunes to change their name. What, the word “Tunes” is branded now? I would have thought they’d worry about the “i”. I’m not so sure that changing XTunes to “Sumitunes” is going to help matters, either…

Posted in Uncategorized | 3 Comments

Random ideas and software patents

(prompted by Greg’s post about OSDL Conference Key Thoughts)

I believe in patenting combinations of software and hardware or human interaction which are genuinely innovative – eg: token ring networking, Lego Mindstorms, the wheelie mouse, that new thing which allows people to see by putting sensors on their tongue, performance-related algorithms such as compression, or security-related encryption algorithms.

Pure software patents, on the other hand… why? Most software is developed as a means to solve a problem. Given the same problem and two decent teams of people to solve it, it seems likely that the two teams will come up with similar designs. Patenting those designs is basically patenting the problem, not the solution. It makes no sense to me. If the problem is already in the public domain, then perhaps the solution shouldn’t be patentable.

So what’s the solution to the ‘problem patent’ problem?

There’s not a lot which can be done with regard to existing patents without some major changes to patent laws. However, for future patents… how about a site where software designs, no matter how strange or silly, can be published? I’m thinking of some kind of library in which any thoughts, architectures, bright sparks, plans, dreams, ideas etc. can be collated against future patents, so that anyone trying to patent things will find themselves losing the court battles on the easily provable grounds that the idea is already in the public domain. This doesn’t have to be restricted to software, necessarily.

For instance:

“How to communicate with Generation Ships and other deep-space bodies, in the absence of faster-than-light travel:
Use quantum entanglement for instant information transfer.”

Now anyone trying to patent the idea of using quantum entanglement to overcome the speed-of-light restriction in deep space communication will find me sitting in the witness box in court. I have now published this idea, and unless someone has already applied for the patent (which wouldn’t surprise me) you are welcome to use it free-of-charge. I’m pretty sure someone else has already thought of Generation Ships.

“How to transfer documents between two different formats, eg: Word 2003 and LateX:
Use a learning AI with pattern-matching to work out the conversion algorithms from other document fragments in both formats, then apply it.”

And so on.

Ideas could be voted on for viability, with the best ideas published to the open-source community for implementation, and the “silly” ideas given negative points… but kept around, just in case.

Carlos reckons that the c2 wiki might be a good place to start messin’.

Posted in Uncategorized | Leave a comment

Firefox support and internet services

Reading Andy’s post on mixed feelings for Firefox, and continuing my attempt to loosen Micro$oft’s hold on me…

I’m leaving one bank because its internet banking doesn’t support Firefox. Their response to my request for Firefox support was “use IE6”. This, to me, is typical of their attitude to customer support.

Smile, on the other hand, have a site which I have run without trouble under Firefox. Not only is their interface great (if you like pink) but their customer service rocks too. So I will be sticking with them, and plugging them to all my Firefox-loving friends (and anyone who reads this).

Andy – can your client afford to lose my custom? Or 2% of the market? Or 5%? At what point does Firefox support become good business sense?

Why not encourage people to use Firefox, and steal everyone else’s customers as they slowly migrate to your way of thinking?

Posted in Uncategorized | 3 Comments

Ubuntu Linux

This weekend, I installed Ubuntu on my home PC.

It’s a bit buggy, but I have high hopes for it. Mostly it’s buggy because I don’t know what I’m doing, but I’m encouraged by the amount of help appearing online.

I think the best thing about it is that it’s designed for Linux newbies, so looking up “Ubuntu help mount windows FAT32 partitions” retrieves posts which doesn’t assume that you know where the fstab file is located, or what “uid=1000” means. You also don’t get forumn posts saying, “Uninstall Windows…”; it’s pretty much assumed that you’re on the right path just by having a version of Linux installed. I’ve got a lot further with it than I did with RedHat, and I’m finding out all kinds of fun geeky stuff as I progress.

That having been said, my dreams of a Windows-free PC are a long way away. So many of my toys aren’t compatible with the Linux programs available – my iPod, my Palm PDA with DocsToGo, my Lego Mindstorms, my Scanner, my bluetooth dongle… the list goes on. And yet, the penguin has just sucked in another victim. Eventually, companies like Apple, Palm and DataViz will have to throw a bone to the Linux users… won’t they?

Posted in Uncategorized | 4 Comments

At 70 words per minute, no one can hear you scream…

I’m writing a series of fantasy novels.

At the beginning of October, I finally reached the chapter halfway through the second book which I’d been looking forward to writing for a long while. I sat on the train, pen poised above the PDA, waiting for the words to come. They trickled in, slowly, but no matter what I wrote it felt dry, stilted and uncomfortable. The meeting between two of the main characters was intentionally awkward, but so, unfortunately, was the dialogue, the thought-stream and the flow of action throughout.

Finally, on Tuesday evening, I started rewriting the chapter from the point of view of another character, hidden and uninvolved in the conversation. Suddenly everything came clear. Six pages in two days is something of a record for me. Six pages in three months is not so good.

It struck me, thinking about it this morning, that efficient programming is all about reducing the gaps between those flashes of inspiration when code flows naturally, makes sense, feels clean and maintainable and not awkward to manage. Ward Cunningham said “our product is understanding” (a quote mailed to me by a colleague from this video). It takes one person a while to come to an understanding. It takes two people working alone the same length of time; neither of them can write anything until this happens. Put two people together, and understanding is reached much more quickly. Yes, both of them could take their understanding away and do some typing, but really, it’s much more efficient to just get the typing done and move on to the next inspiration gap together.

Like fiction, you can write code over and over again, but you’ll end up throwing 90% of it away if doesn’t actually do what it was meant to. If you find your code is stilted and awkward, the best thing to do is to look at it from a different point of view and try again. Ideally, get someone else to give you that point of view. Best of all, grab someone to pair with.

Unfortunately this doesn’t work with fiction, where you as the author are trying to give understanding of your story to others, who have none. Fortunately I have a number of characters on whom I can call for inspiration. So, if you occasionally see me sitting in a dark corner mumbling to myself, you now know why. I am my own pair.

Posted in Uncategorized | Leave a comment

Executing

An Executor is someone who deals with people’s lives after they’re dead.
An Executioner is someone who renders people dead.

Strangely, they both execute. What a pity this code doesn’t.

Posted in Uncategorized | Leave a comment

The XtC, haikus and comments

Last night I went to the XtC, where I met a bunch of very interesting people and discussed best coding practices and haiku.

We decided that while it would be lovely to see comments in haiku-esque form throughout code, to break up the flow of all those strange lines more than anything, it would eventually become distracting and annoying. It got me to thinking, though, about the nature of haiku and the purpose of comments. These thoughts were mostly spurred by Nat‘s article on comments yesterday.

Most people make the mistake of defining haiku as “a poem with five syllables in the first line, seven in the second and five in the third”. The syllables are only really relevant if you’re writing in Japanese. It’s much more important when writing haiku that it should capture a moment in time, giving some unique insight into an everyday event. Normally haikus contain a “kigo”, or seasonal word, to indicate what time of year it is.

Another rule which I’ve heard is that the first line of a haiku should be immediate, something related to the writer. The second should be something more abstract, placing the poem in context. The third should deliver the surprising insight or twist. It struck me that this would in fact be a very good way to flavour three-part comments. The first part should be immediate and tell you why the code section is the way it is. The second should relate the code section to the rest of the system. The third part should deliver an insight which cannot be seen simply by looking at the method signature.

This means that the comment below (from my “Hellbound” variant of Tetris):

public void AbstractShape implements Shape {

    ...

    /**
     * Uses the rotated positions of the shape to determine how it responds
     * to movement.
     *
     * @param movement one of LEFT, RIGHT, DOWN, ROTATE_RIGHT or
     * ROTATE_LEFT. Do not pass the DROP event to this method - break
     * it into separate DOWN events until blocked instead
     *
     * @return true if the shape moves successfully, false if the detritus*
     * or the edges of the board block a move
     */
    public boolean move(String movement) {
        ...
    }

    protected abstract Point[] getRotatedPositions(int newQuarterTurns);
}

*the pile of dead shapes at the bottom of the board

is a haiku-esque comment, whereas this one:

public void AbstractShape implements Shape {

    ...

    /**
     * Moves this shape.
     * @param movement the movement which this shape should attempt
     * @return true if successful, false otherwise
     */
    public boolean move(String movement) {
        ...
    }
}

although shorter, is not.

The first comment tells me things that I didn’t know and ensures that any shapes I code which override this method adhere to a specified contract. It also tells users of the method what they can and can’t do with it (the can’t is more important, as it won’t be covered by tests). It tells me why the method behaves the way it does. It doesn’t tell me what the method does, as that’s covered by the method name and additionally by the tests.

The second comment doesn’t tell me anything which I didn’t know already.

It’s a terrible idea to include extra syllables in a haiku just so that it matches up to some preconceived notion of what a haiku should be. It’s also a terrible idea to include comments just because some strange style checker / team leader insists that you have to have them. A haiku should deliver a surprising insight in as short a space as possible. A comment should do the same. (Thanks, Nat!)

So. Time to go through the bits of code which I wrote before my recent enlightenment, and ensure that the comments are either beautiful or absent. I may need to do something similar with my poetry collection.

Posted in Uncategorized | 7 Comments

My first piece of paid writing

Finally, I will be joining the likes of Martin Fowler et al as a paid, published writer. Two of my poems have been selected for Star*Line, the Science Fiction Poetry Association magazine, and will hopefully be appearing in print later this year.

Admittedly, given the current USD exchange rate, my earnings won’t even cover the cost of a pint in my local – but it still means a lot to me!

Posted in Uncategorized | 1 Comment