avatarharuki zaemon

Pull Me Push Me Anyway You Want Me

By

I recently needed some code to parse text streams. Conceptually, the logic was pretty simple: break a stream into words and combine consecutive words into “phrases”. So for example, the stream "have a nice day" might be broken into the phrases: "have", "have a", "a", "have a nice", "a nice", "nice", "a nice day", "nice day" and "day".

The problem is that I’m not going to own this code in the end, someone else is (permission was given to publish the code) and after numerous consulting gigs over the years, I’ve become very careful to avoid leaving behind any Alien Artifacts. So I produced two versions, each producing identical output but based on very different designs, in the hope that at least one of them would fly.

I’ll start with my first approach which, IMHO, is pretty easy to understand – well I wrote it so I guess it is for me anyway – and an interface that accept tokens as they are parsed (a Visitor of sorts):

public interface TokenVisitor {public void onToken(String token);}

Classes that implement TokenVisitor will be notified anytime a token becomes available for processing.

Next, we want to create phrases from tokens and print them to the console so, we also need a class that takes the tokens it receives, creates phrases of between 1 and maximumPhraseSize tokens and sends them to another visitor (a Decorator):

import java.util.LinkedList;import java.util.Queue;public class PhraseBuilder implements TokenVisitor {private final Queue<StringBuilder> builders = new LinkedList<StringBuilder>();private final TokenVisitor output;private final int maximumPhraseSize;public PhraseBuilder(TokenVisitor output, int maximumPhraseSize) {assert output != null : "output can't be null";assert maximumPhraseSize > 0 : "maximumPhraseSize can't be < 1";this.output = output;this.maximumPhraseSize = maximumPhraseSize;}public void onToken(String token) {assert token != null : "token can't be null";for (StringBuilder builder : this.builders) {builder.append(' ').append(token);this.output.onToken(builder.toString());}this.output.onToken(token);this.builders.add(new StringBuilder(token));if (this.builders.size() == this.maximumPhraseSize) {this.builders.remove();}}}

And finally, some sample usage:

    Lexer lexer = new Lexer(_stream_, new PhraseBuilder(new TokenVisitor() {public void onToken(String token) {System.out.println(token);}}, 3));lexer.run();

Here, an instance of the Lexer class (not shown for the sake of brevity) simply breaks _stream_ into words (tokens) and calls TokenVisitor.onToken() passing each one in turn. The phrase builder acts as the first level visitor and passes its results on to the next level visitor, an anonymous inner class that simply prints each token to the console.

For many people it seems, this push style of processing is not only unfamiliar, but downright peculiar. When I show this style of code to developers – especially junior developers and non-technical people – they find it hard to grasp. Not so much the logic in PhraseBuilder but what stumps many people is the “complexity” of the overall “pattern” and in particular the usage. For many it seems, this approach is all a bit “backwards”.

So for comparison, here’s an example of a more conventional pull mechanism, starting with the interface:

public interface TokenStream {public String nextToken();}

This time we have an interface which we can call to get (pull) the next token rather than be notified (push) as in the previous example. The method nextToken() returns null to signify the end of the stream – no more tokens.

Next up, the phrase builder. Again, we’ll implement the interface – to allow chaining – but this time we’re relying on a pull rather than push mechanism to get tokens:

import java.util.LinkedList;import java.util.Queue;public class PhraseBuilder implements TokenStream {private final Queue<StringBuilder> builders = new LinkedList<StringBuilder>();private final Queue<String> phrases = new LinkedList<String>();private final TokenStream input;private final int maximumPhraseSize;public PhraseBuilder(TokenStream input, int maximumPhraseSize) {assert input != null : "input can't be null";assert maximumPhraseSize > 0 : "maximumPhraseSize can't be < 1";this.input = input;this.maximumPhraseSize = maximumPhraseSize;}public String nextToken() {return this.hasNextToken() ? this.phrases.remove() : null;}private boolean hasNextToken() {if (this.phrases.isEmpty()) {makePhrasesWithToken(this.input.nextToken());}return !this.phrases.isEmpty();}private void makePhrasesWithToken(String token) {if (token != null) {this.builders.add(new StringBuilder());for (StringBuilder builder : this.builders) {if (builder.length() > 0) {builder.append(' ');}builder.append(token);this.phrases.add(builder.toString());}if (this.builders.size() == this.maximumPhraseSize) {this.builders.remove();}}}}

Holy schmokes! That’s a whole lotta code with multiple queues and extra private methods. Surely it can’t be that complicated?

Ok, so how about some sample usage:

    PhraseBuilder builder = new PhraseBuilder(new Lexer(_stream_));String token;while ((token = builder.nextToken()) != null) {System.out.println(token);}

Sheesh! That’s pretty simple. Far simpler than the code in the first example and pretty obvious what it’s doing really and when I show this kind of code to people, they tend to respond with “Oh, I see. That makes sense.”

Considering the relative complexity of the second phrase builder to the first, I find this all somewhat odd: the original example took me about ten minutes to code up and test; the second probably around twenty – at first I tried to do it from sratch but I gave up in the end and resorted to a brute-force conversion approach not dissimilar to that required to convert a recursive algorithm to an iterative one.

In fact, push versus pull is very similar to recursive versus iterative: people tend to have the same comprehension difficulties with recursion as they do with a push-style calling mechanism. It’s a strange thing really because although conceptually simpler, an iterative approach can often be much harder to implement than a recursive one; similarly, a pull-mechanism can be harder to implement than a push-mechanism.

It should be obvious by now that I have a preference for recursion and push-style processing. For one thing it removes lots of getXxx() methods which is no doubt why I like closures in languages such as Smalltalk, Ruby, Groovy, JavaScript, etc. I also find it forces me to create lots of little classes that do one thing and do it well.

That said, I can also see why (and under what circumstances) pull is more attractive: it’s usually easier to manage flow-control than with push. Often the difference between the two comes down to where state is being maintained: In the case of pull, state is maintained inside the stream; for push, state is maintained inside the parser. No doubt why many people have switched from using push-parsing to pull-parsing for XML.

Updated (1 September 2005)

Thanks to Kris for pointing out the typos in my code. I had copied the examples from and made some on-the-fly modifications to reduce their size but it seems I missed a few things – oops.

Godwin's Law of Java

By

While reading A case against Annotations, I couldn’t help but laugh-out-loud at this particular response:

RoR is quickly becoming the Godwin’s Law of Java language related discussions:“As an online Java discussion grows longer, the probability of a comparison involving Ruby or RoR approaches 1 (i.e. certainty).” – Marc Stock

Some others off the top of my head:

  • Any editor and Emacs;
  • Any programming language and Smalltalk;
  • Windows and Linux;
  • …?

Having never heard of the Law before, I did a bit of reading and found, among other things, an FAQ and a paper by Mike Godwin himself.

PGP for Mac Mail

By

If you’ve ever needed (perhaps need is too strong a word, how about wanted) to digitally sign – or encrypt for that matter – your emails from within the Mac Mail client, it’s pretty simple. Even though there are plenty of mail applications that support PGP, I’ve grown fond of Mail.app so this morning – for no real good reason – I installed a few plugins, etc. and was up and running in literally 5 mins (ok 10 mins – I didn’t have a clue what kind of signature I should use).

First go and get GPGMail. The download is a .DMG file and the instructions on the web site are easy to follow. In addition to GPGMail, you’ll also need GNU PG for the Mac (GPGMac and GPG Keychain Access as a minimum).

I also found I needed to go into the Preferences>PGP>Composing and switch on “By default, use OpenPGP/MIME”. This allows signed messages to be sent using MIME rather than the old-school format which surrounds the text in the signature and makes it look as though your email was sent through some kind of full-on nerdifier – a bit scary for mum.

Now that I have the ability to sign emails I’ll just, well, probably never use it really – quite frankly, I can’t imagine anyone being bothered to impersonate me in an email – but at least I feel “safer” LOL.

So anyway, here is my PGP key (valid until August 22, 2006) for anyone who cares:

Key ID: 0xD56C95B07EA87B26Key Type: RSAExpires: 2006-08-23Key Size: 2048Fingerprint: AF94 4D3E F229 1A40 4F79 17DD D56C 95B0 7EA8 7B26UserID: Simon Harris <haruki_[email protected]>

- -- --BEGIN PGP PUBLIC KEY BLOCK -- ---Version: GnuPG v1.4.1 (Darwin)mQELBEMLpCoBCAD1qKqEmXhnbg8unu7n3wL8d8qyqu9M7iIhLMn6ZIxHPe91vXCi3NxCu9J5p+nenKcwyPV4i/TA4G6lr6hGAv6yOkCKXg/kMX/oPoqVALBnzz+NNXXOv9xZ1/DnQuyMXj/JP3u/rMrGErO5BEq+RtxQ3BwdbF8TsEktaaIrPPG/ZRWlSSCnFhTbS4F+J8bNNgmB2M8AYbk5F2FJc68ikSDDKz28F/pF1Xal+O/s3nVtXgQkf6o5sV/YnIGogDP419XQ8C9tb4dqoe8oR8v25g6umNEDcUMtOS3Utyds2q7mfdlczjAuYpixCLk8QMbEfsaQqGJU7b7YjK9iaVJqS/Z3AAYptC1TaW1vbiBIYXJyaXMgPHNpbW9uQHJlZGhpbGxjb25zdWx0aW5nLmNvbS5hdT6JATcEEwECACEFAkMLpCoFCQHf4gAGCwkIBwMCAxUCAwMWAgECHgECF4AACgkQ1WyVsH6oeyZa4gf9Fus1SDOwBYG6RLiQomXWhfHibGZnrssw9ECemI6I81kgKC6rd+srxbiKit09TIMIUzZ/oecNVtxg80rgbYsOT4EGniq/As5c6xfYNcxwgGW00Xf6txvMGCRzkierHWlE0KajOW94AnuAtzHC9vsPVxTjt4dM08IHWS9VeuqGq8ULokcHh9uF4e24s/maJFUGikYm2dACKS8vNPImFHUcV17pTm4gptag4bm1+KmFWS1wnUS/I1jfmUc+xJOrXFRadkEbiYJEi1aaPyvgyvXzupia6RDyMvPfUILZLO1L4be/KGf6R6jdhE4T+9U4dNHbGnukIqkIQLRxgNqhtklgkA===2DOr -- ---END PGP PUBLIC KEY BLOCK -- ---

Of course it occurs to me that someone could also spoof my blog and change the public key here but again, I’m thinking people have better things to waste their valuable time on like say, RAD for example ;-).

Invasion of the Battery-Life Snatchers

By

Over the past 6-9 months, I’ve been doing a lot of development using my PowerBook running on battery. For the most part it works really well: The performance is just fine (with some tweaking of the power-saving settings), giving me around 2 hours of editing, browsing, emailing, etc. That is unless I’m developing code using IntelliJ.

When running in the foreground, IntelliJ seems to use anywhere between 3.0% and 6.0% of the CPU. Not too bad you might think but that is when I’m not doing anything with it. Even when IntelliJ is in the background – either hidden or minimized – it still uses around 3.0% of the CPU as this screen-shot from top clearly shows:

     PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS RPRVT  RSHRD  RSIZE  VSIZE1259 top         14.5%  0:29.70   1    18    22   776K   372K  2.62M  26.9M -- &gt;  670 idea         2.7% 11:11.22  26   &gt;&gt;&gt;   485   270M  28.3M   231M   831M &lt; -- 1248 Safari       0.2%  0:06.22   6   127   238  8.89M  27.9M  18.8M   243M1247 SyncServer   0.0%  0:03.65   2    53    48  12.2M  3.36M  15.1M  47.3M1225 mdimport     0.0%  0:01.11   4    66    67  1.39M  3.27M  5.16M  39.7M668 bash         0.0%  0:00.02   1    14    17   220K   820K   904K  27.1M

A quick check of the Java version indicates that I am running JDK 1.5 by default:

simon$ java -versionjava version "1.5.0_02"Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-56)Java HotSpot(TM) Client VM (build 1.5.0_02-36, mixed mode, sharing)

And a quick check of the About Box in IntelliJ confirms this.

Now admittedly I haven’t tried any other Java applications so I’m not too sure if it’s a Java issue, a Java on OS X issue, an IntelliJ issue or what but it is driving me nuts because it pretty much turns my 2+ hours of battery life into 30-45 minutes.

So if anyone has any idea how I might get IntelliJ to stop using CPU when it’s idle, please, please, please let me know.

Oh and Jeaves, “use Eclipse” and “get a real computer” will not be considered helpful answers ;-)

Update (30 August 2005)

Vote for the bug.

Scraps of JavaScript

By

Not much today but some little bits-and-pieces of stuff I’ve picked up over the last two weeks. It’s been a steep learning curve going from no JavaScript to writing a character-based terminal emulator and it’s sure been fun.

Now that I have a modicum of JavaScript under my belt, I think I’ll finally take Big Daz’ advice and have another look at prototype. I had a quick look initially – on his recommendation – but I was so new to the language that none of it made much sense. FWIW, thanks again to Big Daz, I also spent a lot of time reading quirksmode.org.

Overall, DHTML works really well. The browsers seem to handle running JavaScript pretty well – the performance is quite impressive – and it’s not that difficult to get things to work cross-browser.

So, here we go…

Rather than report an error, most browsers seem to silently fail or at best give a rather less than helpful message – either by way of a pop-up or a message to the JavaScript console.

The error messages in Mozilla – sent to the JavaScript Console – are far more useful than those generated by Safari – also sent to the JavaScript Console; MSIE is woeful when reporting (by way of a pop-up) errors in JavaScript files that have been included via &lt;script language=&quot;javascript&quot; src=&quot;...&quot; type=&quot;text/javascript&quot; /&gt;.

The debugger for Mozilla works a treat.

Methods can’t be named the same as fields – they’re really just the same thing anyway. Not really a problem but I was translating some code to JavaScript and it didn’t work out as I had planned ;-). Either use an underscore (_) for field names; make sure your method names are always prefixed with a verb such as get/is/etc.; or “allow” direct access to fields. I say “allow” because strictly speaking, it seems that field values are pretty much always accessible anyway.

Closures usually require that you define a variable with a value of this to ensure you can always refer back to the object that owns the function being called:

    var **self** = this;orders.each(function(order) {**self**.process(order);});

To ensure your onkeypress event handler is called with an event object, use something like the following to capture the event and then delegate:

    var self = this;document.onkeypress = function(event) {return self.onkeypress(**event ? event : window.event**);}

To have a keystroke ignored seems to require the following code in your onkeypress event:

    event.cancelBubble = true;event.returnValue = false;return false;

This works for most everything with the noteable exception of F1 in MSIE which displays help on the browser. To prevent this, try:

    document.onhelp = function() {return false;};

The Mac generates very odd key `s for things such as Up (63232), Down (63233), Left (63234), Right (63235), etc. I say odd only because I’m used to the ones generated on PCs (38, 40, 37, 39, …). Ok, so maybe they’re not odd just different ;-)

MSIE seems only to allow you to modify the content (DHTML) of a div.

Even though the HTTP protocol allows you to send and receive binary data – using Content-Type: application/octet-stream and Content-Transfer-Encoding: binary for example — none of the browsers I tested would reliably allow the JavaScript code to receive that data as a string of characters, even though the browser would quite happily download the content to a file on my hard-disk and allow me to manually construct a string with identical content – using String.fromCharCode(0x1b) for example.

You can simulate Swings invokeLater by using window.setTimeout() with a time-out value of zero:

    var self = this;window.setTimeout(function() {self.doSomething(...);}, **0**);

Most of the browsers I tested didn’t seem to support for .. **in** ..; they all accepted the syntax but produced kooky results when used.

All browsers I tested support using innerHTML to replace the content:

    document.getElementById(id).innerHTML = html;

Using a span with CSS classes is the simplest way to inline style changes:

    &lt;span class=&quot;important&quot;&gt;...&lt;/span&gt;

Handling errors (and for that matter state changes) when using XMLHttpRequest (or in the case of MSIE, ActiveXObject(&quot;Microsoft.XMLHTTP&quot;)) differs between browsers:

  • Safari and MSIE seem to always set request.status and request.statusText;
  • Netscape/Mozilla seem to sometimes set these variables, yet other times throw exceptions due to the varible having not been defined;
  • Most will allow any old value for request method and URL and notify you via onreadystatechange if there was an error – such as 404 Not Found for example – though sometimes (under what circumstances I don’t recall) they will throw an exception on open() and sometimes on send().

Both Netscape/Mozilla and MSIE append a CRLF (0x0d0a) to the end of any content you send, leaving the Content-Length field two-bytes short; Safari seems to leave the content as-is. Not really a problem but interesting as the data already had the CRLF as usually recommended for sending content via HTTP.

To change the colour of a horizontal-rule (&lt;hr class=&quot;a_style&quot; /&gt) in a browser-neutral manner, you need to set your CSS style as:

hr.a_style {background-color: #NNNNNN;color: #MMMMMM;border: 0;height: 1px;}

You can call a method using a string for the name, allow a switch-like calling mechanism:

    var methodName = (this.insertMode) ? "insert" : "overwrite";**this[methodName]**(aCharacter);

More to come I’m sure. Add any more you can think of or let me know of better ways to do these things as I’m truly ignorant in this space.

Getting Soft or Getting Smarter?

By

Sixteen or so years have passed since I started my first job – a programming gig writing language interpreters and compilers – even though I didn’t really know how to program. On day one I was given an intel 80386 machine code instruction manual, a System/370 machine code instruction manual, a desktop PC, a copy of Microsoft assmbler, access to a mainframe via a 3270 terminal emulator and told to pretty-much work it out myself. And that’s pretty-much what I did.

Sixteen years later, I’m doing some work for the same company. And while a lot of the industry has move on (or was that gone ‘round in circles?) they’re still developing the same software all written in assembler and their proprietary development languages. They do great business selling software for 7-digit figures whilst competing with the likes of IBM, CA, etc. The proprietary language they use – all written in assembler remember – runs on Windows, Linux, OS/2 and zOS and has many of the features that “modern” languages have: dynamic dispatch, loose typing, etc. Not bad for a company with three people, doing it all The Wrong Way™.

My job has been two-fold: write some DHTML and JavaScript communicating back and forth with a web server written in the proprietary language; and add some new features to said language. And, all-in-all it’s been pretty good fun. The DHTML and JavaScript stuff is easy peasy (like we need an acronym for this stuff, sheesh!) and getting back into assembler programming after all these years of Java has been downright good geeky fun. That is of course until something goes wrong.

JavaScript debugging is still a bit lame, even with the Mozilla plugin but that’s easy enough to fix with a few carefully placed calls to alert(). The biggest issue with JavaScript unfortunately is the difference in browser behaviour, especially with respect to keyboard events and XMLHttpRequest. No matter though, we overcame those issues pretty easily and moved on to other things: adding new features to the proprietary language.

It’s probably been 10+ years since I did any assembler programming and I feel it; I’ve become soft. I make my changes and run the application. It touches a bit of memory it shouldn’t and BOOM, memory violation. Right. Register dump. Ick! I remember those. Urgh. Start up the debugger – gdb – and let’s try that again. BOOM. This time though we’re inside gdb so I can start poking around. Right. Where are we? Hmm…let’s look at where eip points – linux on pentium hardware. Ok, where is that relative to the load-point for the module. Ok, <snip>

My forensic skills have become soft. I’ve become too accustomed to exception handling, stack traces, automatic buffer overrun detection, garbage collection, no pointer arithmetic; unlimited numbers of variables, no little- vs. big-endian issues, etc. No peeking into memory to see what the processor stack might look like anymore. Instead, just look at the line numbers and there’s most of what you need to know already in front you.

I’m not complaining mind you– like not needing to think so hard about debugging – but it is interesting to see how my skills have changed over the years and how my current development ideas (and ideology?) have been shaped (for better or for worse) by having a knowledge of the underlying execution architecture. Forget 80x86 or System/370 processors, these days Java, .Net (and no doubt countless others) are built on _virtual machines_ with their own instruction sets, stacks, etc. How many developers actually understand the workings of the underlying VM? How much does a developer gain (or lose) by having this understanding?

Update (23rd August 2005)

Just to show you how soft I’m getting, I changed the design to one that didn’t involve me needing to use gdb LOL.

Prevent Mac Droppings on Network Drives

By

In my current gig, I’m using my PowerBook in an all M$ Windoze (with the exception of Linux servers) environment and it’s working a treat. Except for one thing: all those .DS_Store files.

Finder in Mac OS X (and probably previous versions too I imagine) creates .DS_Store files whenever you browse a directory. The file is seems pretty harmless - apparently it contains little more than window preferences, etc. - and Finder hides them from view.

Unfortunately, it does get the back up of some of the other developers. Not really because the files exist, but more because, for some reason, the files get created with a timestamp in the future which causes all manner of problems for the guys writing their MFC applications - with asserts turned on the applications barf all over the place.

So, I did a quick hunt on google and found this article that explains how to prevent the behaviour. It’s a pretty simple fix and involves entering the following at the command-line (possibly followed by a re-boot?):

> defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Now if someone could only tell me why I seem to end up with all these ._XXX files lying around that don’t appear in Finder, nor when running ls -la but do end up in my zip and tar balls.

You See I Am Trying To Be Objective About It.

By

It was an unsettling feeling, one I was sure I had experienced before.

Seven days ago today, I boarded the good-ship X` bound for the land of Cocoa. I was promised a bumpy but nevertheless enjoyable ride over well charted sea, enjoyable smalltalk and no bugs. Life would be wonderful and applications would spew forth from the finger tips of those who chose to take the journey.

Seven days later, I’m in pain. I’m hurting. I’m surrounded by square brackets. I have a hard time keeping track of my memory (maybe it’s alzheimer’s?). I wish I new what was wrong with me but even the good Dr. GCC seems to have a heck of a time diagnosing my condition. I have a sneaking suspicion it’s a form of jet-lag - I feel as though I’ve travelled back in time (about 15 years to be precise) but I’m not sure.

Humour (such that it is) aside, I’ve been getting into Objective-C the past week as there’s a project I’m about to start working on that is targetted at Mac OS X and will be written in said programming language. So, I thought I’d go head first and use X` as well. Ouch, ouch, hurty, hurty. Why do I feel like someone just cut off my arms and stuck red hot pokers in my eyes? To be honest, I think I should have started off with TextMate and GCC. But nevertheless I’m percervering.

I do like the Smalltalk like features such as dynamic binding and the calling syntax is quite simialr too. I don’t care much for the use of square brackets - though I’m not sure I could come up with anything much better for a language that is (or at least was) essentially a pre-processor for a C compiler. The fact that I have to use pointers all over the place is particularly irritating too.

Ahh yes, I was once a member of the K&R club: First C; then C++. All those calls to malloc & free, new and delete. Endless hours of trying to remember what happens when I use array indexing on something declared as int **. In the end though, I guess it comes down to what you’re used to and for the last 6 years (I think?) that’s been Java; a language that for all it’s short-comings (of which there are plenty), is a pretty simple language to learn and understand - at least it was for me anyway. I’ve become acustomed to garbage collection, packages and object references (the last being syntactic sugar mostly) and I like them. And of course then there’s IntelliJ and Eclipse to help me out, suggest class names, think for me.

So it came as rather a shock to the system to go back to an IDE that seems to require soooo much configuration for apparently soooo little benefit, a language that forced me to think about when to call release to cleanup unused objects, and an overall environment that let me compile and run something that, on subsequent inspection, didn’t even seem to be valid code - more likely a “feature” of X` than any underlying problem with GCC or the language itself.

Of course many of you will argue that I’ve forgotten what it’s like to be a Real Programmer™; that it’s character building. To this I say phooey. I was once an assembler programmer and I loved it. Then I became a C/C++ developer and I loved it. Then I moved to Java and never looked back (well maybe once but nobody saw me do it so you can’t prove a thing). Moving to Objective-C is thus a painful yet disturbingly rewarding experience; like pulling out the old Commodore-64 and playing Galaga: The graphics suck but they’re cute and the game is nevertheless fun to play.

So, the things I like about Objective-C so far:

  • Dynamic dispatch - ie. run-time method binding;
  • Categories - adding methods to objects at run-time;
  • Smalltalk-like calling syntax; and
  • self - I don’t know why but it’s somehow more appealing (or just different) than this;

Things I dislike about Objective-C so far:

  • Manual (yes as far as I’m concerned even reference counting is manual) memory management;
  • Square brackets;
  • + and - for marking static and instance methods respectively;
  • @whatever - smacks of pre-processor hackedy hack hack hack; and
  • Needing to manually call the super “constructor” - it’s not really a constructor so, yes, I know why it’s necessary but it still sucks.

But in the end, who can resist the sexy look-and-feel of Mac OS X apps? Not I. And I want to try my hand at creating some so what better way to do so than Objective-C/Cocoa. I’m assured that once I get into using the Cocoa stuff, life get’s a lot more fun and interesting, fingers crossed. Or perhaps I’m just too old and grumpy ;-)

If anyone has tips, links, experience they’d like to share on how to make this a more pleasant journey (no, shut-up and take it like a man doesn’t count), please please please let me know.

Not Writing Myself Off Just Yet

By

Finally, after some travelling, I’m back in Oz having spent some time in Ladakh (Northern India), France, U.K. and Canada, all the while trying to write my first technical book.

The book (yet to actually be published mind you) was handed to me by Jon Eaves, no doubt meant as a cruel joke or perhaps punishment for some as-yet unspecified crime I must have committed ;-)

It has been a bit disheartening at times. For a start, I knew that I knew nothing about writing before I started but I now know how little that actually was. I take some comfort in the knowledge that as a complete newbie to the whole writing game, I wasn’t supposed to have known anything anyway. Having never completed a degree (I left school at age 17 to start working) and thus never having written much if anything except for my occasional blog entries (and whatever is necessary for work), my capacity to fill pages with words was (and probably still is) severely limited.

Then of course there is the tragic development process that is book publishing. For a start, you have no idea what they actually want so you do your best and start handing in chapters. As the weeks go by and you hear nothing in the way of feedback, you start to worry so, inevitably you spend more time on each chapter trying to get it “right”. Eventually the chapters are returned to you. Some are great, some need a bit of work and others are unrecognisable, let alone unintelligible to even me, the original author! I’m not sure how to resolve this problem though as everyone I speak to complains about the same thing.

I should also never have travelled while writing my first book: I discovered that I’m a single-threading processor, just as the stereotype for my gender suggests. Though to be fair, I’m not sure this really contributed as much as simply Not Having a Clue™.

I learned that standing up in front of people and giving a talk, a presentation or even teaching a class, pales into insignificance when compared to writing a book (at least for me anyway). Get my gums a flappin’ and there’s no stopping me; put me in front of a computer to type out a chapter and ………………………………. Exactly! Nothing. Nada. Bupkis. Zero. Zilch. Nanimo. I found myself having to talk out loud to an imaginary person just to get my brain into gear.

Then of course there is the subject matter: Algorithms. A topic covered by so many books that surely only a mad-man would attempt another. This one is different though. It attempts to cover each algorithm at a conceptual level in a way that most people should understand. The code itself is unit-tested and the implementations are not merely a re-hashing of C-code just to get the word Java on the cover. So in that sense I’m quite proud of the effort - I’m yet to see the final product.

On another positive note, I think my coding has improved. I’d like to say that I experienced some epiphany and suddenly became a better `r but alas, the motivation was far more down-to-earth: I’m lazy. Having to explain code in words can be difficult and at times a little, shall we say, uninteresting so, the smaller and simpler I can make the code, the easier it is to explain. The down-side is that my coding style changed about 2/3 of the way through writing the chapters. Oh well.

Fortunately I also had James (another book-writing newbie) helping me out. Unfortunately we ended up on different sides of the planet. Fortunately, against all advice to the contrary, our friendship surived with flying colours; If anything it’s made me realise how much better it is to regularly pair on things.

And lastly, I think I’d like to write another book though my approach would be very different. We’ll see if anyone is willing to risk it a second time. In the meantime, it’s back to my greatly-missed training schedule, get a haircut, and get a real job.

Dis-appointment

By

I do quite a bit of travel and I’ve always wished that travel agents would send my itinerary as an electronic invitation but they never do. In fact none of my customers do either. Actually, come to think of it, pretty much no one does. So why don’t more people use ICalendar and VCalendar when sending out meeting or appointment invitations?

At one point in my career I was forced - against my will - to use Lotus Notes and yet one thing we all did was send each other meeting invitations. However, rarely if ever have I seen them sent outside of an organisation. This seems rather strange to me as almost every email application I can think of supports one or other of the formats: Mac Mail; Outlook; Thunderbird; Eudora; Evolution; even Lotus Notes!

For example, Mail+iCal on my powerbook allow me to send and recieve invitations. My calendar is automatically updated when an invitation arrives and updates are automatically sent out when I change one that I’ve initiated.

Have I missed something or is there some reason I have to manually create and update all my appointments?

Desperately Seeking Key Bindings

By

As you’re no doubt aware by now, I’m a Mac weenie (one of us, one of us, …) and have been for 9 months or so now having switched from Gentoo Linux - I got sick of managing my irrational need to constantly upgrade and re-compile the kernel.

When I made The Switch(tm), it took me a few weeks to re-learn the keyboard so that I could get back to using mac apps the way I had used X and before that Windoze apps. I’m also an IntelliJ weenie and the one thing I’ve found that frustrates the hell out of me is that the keybindings (for the Mac) are totally and utterly non-standard. For example, I want to use Command-W to close a tab.

I know I could go in and change the keymap myself but there are probably dozens if not hundreds of commands to map and, as I’m fundamentally lazy, I figured I’d make a plea to anyone who may have performed this heroic effort already ;-). So, if anyone out there has a comprehensive Mac OS X keymap for IntelliJ, feel free to fling it my way and in return, I’ll…um…sing your praises?

P.S. telling me to use Eclipse or be a real man and use VI key bindings aint gonna cut it either - I prefer IntelliJ flavoured kool-ade ;-)

Make Core Values Explicit

By

A developer friend of mine asked me recently what he should do when he discovers that a feature he is working on looks like it’s going to take longer than expected. Of course I recommended alerting the team lead, project manager, etc. “Well that’s fine, but then they just tell me to do it in less time and I can’t!” was his response, to which I replied “Of course you can, just take some short-cuts.” My friend retorted “but I don’t want to compromise the quality of the code!”

The problem here is that as a Developer he wants to write the best quality code he possibly can - irrespective of whether he is capable of doing so or not. His Project Director on the other hand has a deadline to meet. Unfortunately no one has made it explicit which one of these values is more important.

We all live our lives by certain values. When we do stuff, we make value judgements. We decide whether one thing is more important to us than another. Some people are aware of this others are not. Some people are acutely aware of their own values while others aren’t. For some people these values are explicit while as for others they are implicit.

Projects are no different. In fact I’d say it is critically important that the values for the project be not only explicitely enumerated but also prioritised. If this isn’t done, there exists too much opportunity for ambiguity. Ambiguity leads to conflict and conflict leads to the dark-side.

When we start any project - or restart as we have just done - one of the first things we do is to get the stakeholders in a room and prioritise the core values. Things like (honestly in no particular order):

  • Time-To-Market;
  • Within Budget;
  • Customer Satisfaction;
  • Adding Value;
  • Functioning Software;
  • Software Quality;
  • Team Satsifaction;
  • Stakeholder Satisfaction;

It can be tough to do and some people may be a little shocked by what they find out. In my experience for example, Team Satisfaction is almost always at-or-near the bottom with Software Quality hovering around the middle and Time-to-Markert and Within Budget right at the top. When developers see this they initially freak out. “What!? They don’t care about us?”

No, they do care, it’s just that if there’s a choice to be made between you staying back to meet a deadlne and you going home to <insert favourite TV show and-or-computer game here>, then guess which one wins out?

Of course priorities can change and there are no hard and fast rules but if decisions are being made that would appear to contradict the agreed priorities then alarm bells should be ringing as clearly, more communication is needed to work out why.

I dare say companies ought do the same thing. When an organisation says that it considers employee satisfaction to be the highest priority, why not make it explicit? I don’t know about you but rating employee satisfaction above say having everyone billable or customer satisfaction, is highly unlikely but hey, some organisations do tout themselves in this way. I’m sure some employees would be shocked to see the order of values that their managers have in their minds.

The fact is that it doesn’t really matter what the priorities are so much as they are made explicit. Once everyone knows, then decisions can be made and, importantly, made with the full understanding of why and how the decision was reached. The alternative leaves people assuming and expecting things based on their own set of values. Allow people to make informed decisions.

So the next time you’re asked to comprise, realise that it’s probably because the decision is not being made based on your values. Instead, find out what values are being used. If it’s on a project then put the responsibility back on to the person holding the purse strings to make that choice. It’s not a choice you should be making nor one you should even be allowed to make. Then, get over it and do your job :)

Mine's Better Than Your's

By

I’m more than a little amused at the current Rails versus Hibernate versus EJB3 versus whataver, debate that is raging at the moment. It’s not that I don’t mind a bit of argy-bargy. I think this kind of discussion is very healthy. I am a geek after all. I just find it all a little, well, tiresome sometimes. I probably wouldn’t mind so much if the arguments didn’t center around what is supposedly “best”.

Mac users would argue that OS X is better than windows, though windows sales surely outstrip OS X sales by a few orders of magnitude I’m sure. BMW drivers would argue that even the bottom of the range BMW is better than say, a top of the range Toyota, though again, I’m sure that’s not reflected in actual sales numbers. And then there is of course the oft-cited BetaMax versus VHS, IBM’s MCA versus Intel’s ISA. Motorcycles with Mick Doohan’s name on them sell for much more than those without. The guy in the motorcyle shop will thus try and convince me they’re better because they are “popular”. Just because a piece of software (or anything for that matter) is popular, doesn’t make it good. That is of course unless your definition of good is popularity.

Natural selection - and that’s how I see this - doesn’t necessarily choose the “best”, it merely chooses the fittest and, unfortunately, the fittest may well come down to things like, documentation, sales & marketing, how many other people seem to be using it and, gasp, how many books there are on the subject.

Most of the time I hear the argument for using Struts (for lack of a better example), it’s more about the fact that most people “know” struts and very little about whether it is good or not. In fact, my experience is that, while it is pretty easy to get going using Struts, it’s also very easy to shoot yourself in the foot. To the point that I’ve rarely, if ever, seen it used well. That’s not to say that it can’t be used well, just that it usually isn’t.

There are far too many factors that affect the software development process that go waaaaaaay beyond the technology and tools you use. I’ll put my nuts on the line and say that most if not all project failures have little if anything to do with the technology (except as a consequence) and are more to do with the the failings of the people, the skills and the communication.

No, what I want to see is some empirical evidence that says, hey, we built a large scale app in whatever tool it is and look it performs well, the customer is happy, our defect rates are very low, we delivered on time, on budget, and the quality of our code is excellent. And I want you to prove to me that it worked BECAUSE of the technology and not JUST because it had some really good developers on it. then, perhaps then, I’ll go recommending to a customer that they shell out a gazillion dollars to fund my latest passing interest in a tool I read about on the internet and became interested in because I was so bored with whatever tool I used on my last project.

And it’s not even that I don’t like the look of all these tools. It’s not that I’m not interested. In fact I am bored with the stuff that I write most of the time. I’ve been hangin gout for ages to find a project where someone will give me money to play with Ruby. But that’s not the problem I’m being paid to solve nor likely even the problem that I have - the two may well be different!

So rather than tell me why it’s so good, instead explain to me Why I Should Care™. (Because there are 5 books on it is not a valid answer.) Tell me how it solves a problem that I do have rather than how I can do the same things I’m already doing, differently. As far as I can tell, a lot of it comes down to personal preference and pissing competitions.

Two Tigers For Two Days In Two Minutes

By

I’ve been playing with Tiger (OS X) and Tiger (JDK 1.5) for almost 2 days now and I like it. Spotlight rocks. Dashboard widgets are neat and finally I get to do some stuff with Java 5! So here are some some observations and a few gotchas I’ve discovered so far.

First up I did an archive and install so I admit I didn’t start with a totally clean slate.

Overall OS X 10.4 seems to be a little slower and a little buggier than 10.3. Safari hangs or crashes on me every now and then and the little colour wheel is becoming an all too frequent experience. Again this may be due to the fact that I did an “upgrade” rather than a fresh install. A friend of mine did suggest that perhaps spotlights indexing was chewing a bit of CPU from time-to-time. Not sure. I’ll have to wait and see.

The RSS reader in Safari is beautiful though rather less than I had hoped for. Seriously, it would have made much more sense to build RSS support into the mail client than the web browser. There doesn’t appear to be any way to see at a glance, which feeds have new articles. The only way seems to be to “show all” in which case my news feeds totally swamp any others that I might be interested in. Maybe it’s just what I’m used to so, we’ll see how it goes.

Speaking of mail clients, Mail 2 as it’s now called has had a new face-lift and I can’t say I’m that impressed. I kinda liked the old L&F. They’ve taken away my Outbox and status bar. I had found both of these particularly useful when accidentally pressing send before I had completed an email. Again, maybe I’m just a doofus but I can’t see anyway to turn these back on. Guess I’m going to have to be more careful when I compose my emails from now on.

Spotlight (Apple+Space) is pretty damn cool even if it is probably little more than a Google Desktop but I like the fact that it’s built in, let’s me search inside files as well as through file names and it’s fast enough (for me) that I’ve stopped using Quicksilver. Spotlight categorises files that it finds; one of those categories being applications. It has integration with mail, safari, address book, etc. so it’s able to search all your emails, bookmarks, contacts, you name it. This is not to say that spotlight can really compete in any way with Quicksilver, it can’t. But I’m no power user and it was really only an application launher for me so I can probably live without it, maybe.

No matter what your feelings on the OS are, if you want to play with JDK 1.5, then you have little choice but to switch over - Apple aren’t going to ship a version for 10.3.9 or below. I downloaded and installed JDK 1.5 and followed the instructions on how to make it the default runtime for applications. This meant IntelliJ now starts up using Java 5 runtime but running java from the command-line still brings up JDK 1.4.2. The trick it seems is to play with some symbolic links in the bowels of the totally non-standard distribution that apple concocted for reasons known only to a select few I’m sure. So, to get JDK 1.5 from the command-line, I found I needed to do the following:

> cd /System/Library/Frameworks/JavaVM.framework/Versions/sudo rm CurrentJDKsudo ln -s 1.5 CurrentJDK

On that note, the latest EAP of IntelliJ seems to be a lot more stable. I’m not sure if it’s the EAP, JDK 1.5, OS X 10.4 or a combination but whatever it is, I’m grateful as I was getting sick of the weirdness with dialogs losing focus and disappearing on me all the time.

The dashboard (F12 by default) is rather like Konfabulator only it resides on a transluscent pane that appears on top of all other applications. I’ve been using the Weather, Calculator, Translator and Dictionary widgets quite a lot. Unfortunately the YellowPages widget is for US numbers only. Ooh ooh, the Flight Tracker is very cool! Not sure how often I’ll actually use it but it is pretty neat.

I also use the World Clock. Like all widgets, you can have as many open as you like on the dashboard. I currently have only three open: one each for London, Calgary and Bangalore :X. Two widgets I’d like are one for monitoring my email and another for tailing a file such as the system log. Anyone?

My next little hack is to do with the Weather widget. It seems that when creating the widget, the developers decided that evey user would of course be residing in the US; try putting in Melbourne for the city. I had no idea there was a Melbourne in Florida! But after a little sniffing around the AccuWeather website I discovered that they have a “special” syntax for describing “foreign” cities: CountryCode;StateCode;CityName which in the case of Melbourne, Victoria, Australia, translates into AU;VT;MELBOURNE. So, I thought I’d try putting that into the weather widget and bingo! I now have weather for the “real” Melbourne ;-)

I use iSync with my Motorola V3 Phone and my iPod and the new version definitely works better than the old, not to mention synchronising more of my contact details.

And that’s about it I think. Oh, the only other observation I’d make is that I do get the impression that the battery-life is a tad longer. That seems strange to me and maybe it’s just hope played out as reality but anyway, I’ll be curious to see how long that impression lasts ;-)

So, was it worth the price of admission? I’m yet to be convinced. It’s all fun geeky stuff but not much substance really when it comes down to it. Certainly most of the new features I could have had already simply by using more mature 3rd-party tools but hey, I’m a technophile so, as much as I’ll berate people for wanting to play with cool toys at work, playing with them in the privacy of your own living room is an entirely different story ;-)

I Suppose I should Be Flattered

By

I was doing a little reading on different types of rule engines today and stumbled upon this article. As I was reading through it, I had an eerie sense of dejavou; I was sure I had read this somewhere before. In fact, it almost sounded like something I might have written.

A quick search through my blog and there it was, an entry posted in September 2004.

The thing that amuses me most about copying someone elses stuff word-for-word is that you inevitably end up copying all their (or in this case my) mistakes as well. So whilst I’m flattered that someone with obviously unquestionable integrity would even consider re-using my thoughts (and even spruce them up a bit in the process) I would have thought that bloggers, armed with trackbacks and hrefs, and indeed developers in particular, would have left copy-and-paste re-use behind.

I've Finally Been Subversioned

By

Having been berated for bashing subversion based on heresay and rumour, it was about time to make the switch and actually see for myself what life without CVS was like.

As luck would have it, the guy who does all my hosting had already been considering providing SVN support so that when I asked him he was more than happy to make a guinea-pig out of me ;-)

As I didn’t do the conversion from CVS to SVN myself, I can’t comment on what is involved but I can say that it appears to have gone seamlessly and without fault. I installed the latest SVN client on my mac and was up and running within minutes.

Initial impressions are good: The command line application is very straight-foward and somehow seems more intuitive than the CVS equivalent; It certainly runs faster than CVS (or at least appears to) as it only sends diffs to the server (based on checksums); and; It will really come into its own in a week or so when I will need to perform a bulk rename of files for the book - the real reason I needed SVN in the first place.

The only mildly dissapointing thing is the rather less than wonderful support in IntelliJ: Even in the latest EAP versions it seems to be much slower than the command line application and doesn’t have an option for hiding the .svn directories. No doubt all of these will be “fixed” soon…right?

The best part for me is the repository versioning: every commit increases the repository version number so in effect you get a new tag with every commit. This will come in particularly handy for some code analysis tools I’ve been developing that track metrics over time. Previously I had to go through hoops to try and work out what changed and when in CVS. Now SVN gives me this information for free!

So all in all it’s happy sailing on the SVN ship. That is of course until my repository becomes corrupted. JUST KIDDING!

Writing Readable Code

By

Sometime ago I wrote about my experiences pairing with James and the effect that listening to your code can have on the naming of variables, methods, classes, etc. Then last night, I had a very interesting discussion with Owen Rogers about, among other things, the effect that TDD has on your code.

One of the observations was that, in order to write a test (and by inference mainline code) that is understandable, you need to name your methods very carefully. The specific example that Owen gave was a factory method for creating an XmlWriter. The usually accepted convention is to name the method createXXX or newXXX as in:

public class XmlWriterFactory {public XmlWriter createWriter() {...}}

Which would then be used something like:

order.write(factory.createWriter());

The problem with this is that it doesn’t really flow particularly nicely. To illustrate, let’s re-write this last line of code into English:

order (dot) write, factory (dot) create writer

Reading the this aloud seems a little unpleasant and requires you to think a little too much about what is going on, even with such a simple line of code.

The suggested improvement was to buck the “trend” and rename some of the methods so that the code would look something like:

order.**writeTo**(factory.**xmlWriter**());

This can then be converted plain English that reads something like:

order (dot) write to , factory (dot) xml writer

Much nicer! Written this way, it’s much easier to get a feel for what is going on and for that matter to ignore the occasional syntactic noise such as “dot” (and for that matter “factory”). Interestingly however the necessary changes to the factory class make the class itself seem a litte odd:

public class XmlWriterFactory {public XmlWriter **xmlWriter**() {...}}

If you looked at the modified factory class in isolation it might not be obvious what the method xmlWriter was doing. Because there is no verb attached to the name, we have lost some of the meaning of the method when viewed on its own. And, to me, this is one major difference between a traditional design-your-classes-up-front approach, versus a more design-your-classes-as-you-need-stuff strategy.

It seems there is a trade-off between understanding a class in isolation versus understand its use in context and the nice thing about simple, readable tests, is that they give you that context as well as all the other benefits associated with good quality unit tests.

Of course this doesn’t help much if you’re building an API that needs to be used by someone else. Chances are you probably don’t distribute your unit tests and even if you did, people still feel less comfortable reading test code than mainline code or JavaDoc. Having said this, it has always been my experience that no matter how good the documentation is it’s usually almost impossible to work-out how a library should be used (especially one that is composed of many small objects) unless you have concrete examples - code presented in context.

There are obviously many other factors that affect the readability of code and naming is but one however I do find all this particularly interesting as it challenges many of the assumptions, habits and conventions that I, and plenty of others, have formed over the years.

Even more interesting to me is that some approaches favour understanding by novices while others seem to benefit more experienced developers - what seems like the simplest thing™ to one person is completely unobvious to another.

When is a String not a String?

By

So I’ve been stumbling along writing this book and today I wrote some code where, rather than using good old Strings, I instead chose to use CharSequences. Why?

Well for one thing, I wanted to be able to process both Strings and StringBuffers alike and, thanks to JDK 1.4 and JSR-51, that’s possible as they both implement CharSequence- very nifty indeed. More importantly though, I wanted to be able to process data from files as well as in-memory.

Now, admittedly I could have written my code to process Readers or InputStreams instead and used a StringReader, etc. But really, when it came down to it, the algorithm I was writing suited strings and characters not bytes and buffers and all that hoo-ha and I wanted to keep it that way.

So, I thought to myself, I would do the opposite. I would write a CharSequence that wrapped a Reader. That shouldn’t be too difficult now should it? But then another thought occured to me. Before I leap into writing a whole bunch of code that I’d need to test and gasp maintain, maybe someone else had already done the hard work for me; maybe even the JDK!?

A quick flick of the wrist and IntelliJ brought up a class heirarchy for me and what do you know? along with String and StringBuffer was the little used CharBuffer from the NIO package. Another little present courtesy of the JSR-51 group.

A CharBuffer facilitates, among other things, memory mapped I/O, meaning you can address a file on disk as if it were a contiguous array of characters in memory. And, because it conveniently implements CharSequence, can be passed into my code just as any of the purely in-memory implementations.

The other thing I like about CharSequence is that it’s an interface. This makes it possible to decorate them and gather performance statistics really easily. Yes, yes, all you AOP weenies sit down and stop waving your arms about. I know your new (ok not so new anymore) fandangled whizzbang toy can do that too. But I don’t have to learn a new language or tools to do it. One day perhaps but not this one in particular. Believe me, my paradigm has been shifted quite enough and I’m giving it a rest for a while ;-)

The only thing missing is that, surprisingly, the Character class doesn’t implement CharSequence. I’m not sure how useful that really would be but I like the idea if only for completeness sake. It certainly wouldn’t be hard.

Anyway, I think I’ll be looking for opportunities to use my new best friend where I would usually have used a String. The only caveat is that a String is guaranteed to be immutable while a CharSequence isn’t. Oh and you can’t be guaranteed that equals will work between them either. No matter, I can still see the glint of those shiny golden nails from here :)

The hidden chambers that nobody can understand

By

Not usually one to rip off someone else’s quote, I couldn’t resist this one. It’s possibly the best description of corporate software development I’ve seen:

If you look at software today, through the lens of the history of engineering, it’s certainly engineering of a sorts but it’s the kind of engineering that people without the concept of the arch did. Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. – Alan Kay, creator of Smalltalk

If you’re interested you can read his other views on software development and languages.

It's Like Being Back At Work Only I Don't Get Paid

By

I’ve taken 6 months off from regular, full-time, consulting work. After nearly 16 years divided between software development and martial arts training and teaching I needed a break. I’d never really had a real break; If I wasn’t working, I was in Japan training. That, coupled with my ever growing disenchantment with what can only be described as glorified body shopping, prompted me to take a 6 month break.

It has been fantastic for many reasons. Suffice to say, I’ve been enjoying at least a glimpse of how it might feel to one day be independently wealthy. Alas, I fear that day may never come but, fingers crossed, never underestimate the power of positive thinking! Now where did I put that lotto ticket… ;-)

The timing was perfect; no work; lots of free time; and as fortune (or have I spoken too soon) would have it, an opportunity, along with a contract, to write a book landed in my lap. Nothing particularly rivetting mind you; Nothing earth-shattering nor ground-breaking. In fact a topic that has, in most peoples estimation, been done to death. But, if the publisher thinks there’s a market, then who am I to knock back the chance to show how inept I am with the English language, not to mention demonstrate to the world how truly woeful my coding skills have become. Besides, it’s a topic I personally find interesting.

And so it came to pass that, after nearly two months in the wilderness, I finally found something to rant about!

For a start, having a publisher and editor and all the hooha that goes along with producing a manuscript, is really no different than having a customer that wants a bit of software written. They have deadlines. They want upfront estimates and plans. They think that somehow, magically, I’ll know at day one what the entire book will look like down to 5 levels of headings! And worse, when you send them a sample chapter, they write back saying, “thanks for that but not only is it not complete, it could do with some pictures, and go into a bit more detail.” Riiiiiight. That’s like asking a user for feedback and recieving “um, it doesn’t work”. They don’t seem to understand that I don’t write Mills and Boon for a living. I’m a geek. I write, well, geeky stuff. Like code and scripts and, well more code.

Don’t get me wrong, I do enjoy writing. Actually I think I enjoy hearing the sound of my own voice more than writing but that’s another matter. What I’m not keen on is writing for 10 days, submitting it, and finding out that “um, actually, no. Sorry. That’s completely wrong. Please start again.”

The publishing industry seems to run waterfall. I was absolutely astonished. It had never even occurred to me that would be the case. They expect you to have a finished chapter submitted pretty much in it’s final form. First time. Every time. The idea of submitting a half-baked chapter for a sanity check seemed almost abhorrent to them. “Dear god!” I thought. “What is an editor for?” Not what I had originally assumed, obviously.

I need constant feedback. I need to know if I’m heading off into the rapids, not once I’ve capsized, but at least a few days before if possible. I also want to work on different chapters at once. I’m more than happy to add a bit here, a bit there, move stuff around. That’s just the way my brain works. I like to put together little pieces of the puzzle, bit by bit. I like to layer on the different aspects of the work; tests; code; explanation; bit of introduction; etc. It’s the same approach I take to writing code. I guess that’s just how my brain works.

So, after a bit of back-and-forth with my editor, we finally got it all straightened out. She was most understanding and very helpful. She explained what she needed and why. She expanded a little on the areas she thought needed more explanation, figures, etc. And once again I was happy with the content. Nevertheless the process remained waterfall and this continued to bother me.

After a little brainstorming with my saviour in all things planning, James, the antedote became clear. I just needed to do what any self-respecting agile bigot does in a waterful infested pool; erect a facade; interpose another layer between myself and the editor; make it appear that there is a perfect, uninterrupted, cascading of chapters from top to bottom. We decided that it would be a good idea to use my work colleages and a couple of my siblings (both geek types) to review and comment on what I was doing as I went. They would understand I hoped. They knew what it was like. Then when we were happy with the content and layout, I’d send the completed chapters through.

So here I am at the beginning of the last 28 days of the first 25% of my first book, changing tack mid-stream and paddling like crazy in the vain hope that I won’t fall over the edge of a literary Niagra Falls.

God Speed!