Up to Main Index                              Up to Journal for June, 2012

                      JOURNAL FOR WEDNESDAY 13TH JUNE, 2012
______________________________________________________________________________

SUBJECT: Monstrous code
   DATE: Wed Jun 13 23:10:48 BST 2012

Sometimes it pays to just think. For about a week now I've been overhauling
the high level I/O layer in the WolfMUD prototype. It all started so
innocently...

I was documenting away and realised that the prototype had movement and
locations implemented. There were also 'things' such as the ball and lattice
I've shown before in screenshots. However they were only decorative and you
couldn't interact with them. So I decided that the prototype should have
locations, movement and basic objects implementing at least the get, drop and
examine commands.

So I implemented an Item which is a Thing with some extra attributes attached.
So far so good. However you could now get the objects, quit and destroy the
objects leaving anyone else with nothing to do - not that there is much yet
anyway[1].

So I now had to implement dropping of a player's inventory when they quit.
Easy enough. However it was very ugly. If a player saw you drop everything
they would see:


  >
  You see Diddymus drop A small ball.
  >
  You see Diddymus drop A curious brass lattice.
  >
  You see Diddymus drop An iron bound chest.
  >


I now had to implement buffered messages and broadcasting, which I had hoped
to avoid in the prototype. This proved ...  messy - I had multiple solutions
but none of them elegant, maintainable or invisible to other developers. After
several abortive attempts I left the code alone for a few days and just mulled
over the problem twisting it this way and that, a poke here, a prod there.
Still nothing elegant came to mind... so I just walked away totally for a few
days.

This evening I brewed some really strong black coffee, rolled up my sleeves
and attacked the problem head on. It wasn't pretty. I ripped code apart, wiped
out parts of it, rewrote huge swathes, fought mercilessly with the compiler
errors and banished them one by one[2]. Eventually it all fell into place and
finally I had:


  >
  You see Diddymus drop A small ball.
  You see Diddymus drop A curious brass lattice.
  You see Diddymus drop An iron bound chest.
  >


Yay! :|

Well it's a bit more impressive than it looks as this is automatically handled
throughout the code without having to do anything special ;)

Now? I'm back to documenting the code and all the changes I made *sigh*

--
Diddymus

  [1] For Items I also added units for weight - with provision for units of
      currency, time, length and any other units.

  [2] This may have been exaggerated just a smidgen or a tad - take your pick.


  Up to Main Index                              Up to Journal for June, 2012