Motorway Algorithms

“The problem”, explains Michael, our company’s token Irish programmer, “is that the script, getItemListing.sql, needs to run before getItemCosting.sql”.

“In fact that script really needs to run before any of the others”, he points out further. “Otherwise it will reference stored procedures that have not yet been created”.

“Right”, I say. “So what do we need to do to fix it?”.

“Well, we could rename getItemListing.sql to 1_getItemListing.sql”.

“Sounds messy. And then what happens when we have another script that should run before 1_getItemListing.sql?”, I conjecture.

“Yeah, I dunno, I guess we’d have to rename it to something like 11_*.sql”.

“Ah, it’s the motorway problem”, I say.

“Huh?”.

“When TRANSIT built the Auckland motorway system back in the 50s, they needed an algorithm for labeling exits”, I explain. “The most logical solution would have been to name them sequentially from south to north. But then of course what happens when, in five years time, they add a new exit between Exit 4 and Exit 5? They might call it Exit 4a, but in another five years time, there might be a another new exit between Exit 4 and Exit 4a.”

“And then later Exit 7 gets decommissioned”, adds Michael.

“Exactly. They needed a better solution. So, in the end what they decided to do was to label the exits based on the number of kilometers from Cape Reinga”.

“Hey, I hadn’t thought of that. That’s actually really clever!”

“Yeah, it seems to work reasonably well”, I say. “As you drive south, exit numbers are all unique and always increasing”.

“So then, do you have any suggestions for what I should rename my script to?”, Michael asks.

“Um no. Let’s just call it 1_getItemListing.sql”*

*Distance to database doesn’t seem to work

This entry was posted in IT. Bookmark the permalink.

8 Responses to Motorway Algorithms

  1. Alicia says:

    You have a Irish programming working with you?!

  2. Ian says:

    Just copy /etc/rcX.d naming, and use two (or more) digit prefixes.

  3. michelle says:

    He looks Irish.

  4. michelle says:

    Thanks for the tip, will investigate : – )

  5. Alicia says:

    Is it the one that can’t smile or the one that has funny habits?

  6. michelle says:

    Um, I think that pretty much sums up most software developers that I know.

  7. Simon says:

    Hey! You do know we read this right!

    Anyway, what funny habits?

  8. Alicia says:

    Funny habits include only sitting on white chairs and not brown chairs, doesn’t use keyboard shortcut at all, drinks ginger beer disguised as normal beer, only types with 2 fingers… The list goes on :)

Leave a Reply

Your email address will not be published.