Up to Main Index                           Up to Journal for October, 2015

                    JOURNAL FOR TUESDAY 13TH OCTOBER, 2015
______________________________________________________________________________

SUBJECT: Code Hygiene
   DATE: Tue 13 Oct 22:58:48 BST 2015

Last Wednesday pushed some updates to the public dev branch of the WolfMUD git
repository. Then, silence. Even the gentle glow of the blinking cursor seemed
more subdued than normal.

I did draft an entry Sunday night on my tablet. Reading through it later I
decided not to publish it. Don't worry, nobody has missed anything except a
load of really awful waffling :)

Now I shall sit, compose my thoughts and attempt to write something that is at
least semi-interesting.

I've recently updated the downloads page[1] on this site. Thanks go to Michal
"Mcgiwer" Dziczkowski for the suggestion.

Both Michal and Josh have made other suggestions for the site which I started
looking into but hit a snag I haven't had for ages - where did the source go?
The WolfMUD site is composed from plain text files. I have a tool I wrote ages
ago that turns text files into HTML files - it wraps the text in a minimal
HTML boilerplate, makes links, makes link descriptions, builds directory
indexes and one or two other things.

Normally I do quick hacks using a combination of bash, Perl, sed and awk. If I
need it on multiple machines I just copy it around. Originally the tool was
written[2] in Perl with a little bash. For WolfMUD I rewrote it in Go[3]. Now
here comes the problem: With bash, Perl and any other scripting language you
carry the source around with you - the source is the 'executable'. Now I had a
copy of my tool on various machines and multiple copies of the source on each
machine - I wasn't 100% sure which sources matched the latest version of the
tool! A very good example of very bad code hygiene :( Generally I'm not that
bad - quick hacks are just that, actual projects are managed with Git. What
had happened was the tool had started out as a quick hack but later developed
into its own project - but was still being managed as a quick hack.

I now had a mess, of my own making, that I needed to sort out :(

I was pretty sure that the binary was built from a set of sources on the
machine it was on. In other words I wouldn't have just copied the binary,
except in a single specific instance - the live version! *groan*

First thing I did was to get the SHA512 checksum of the live binary and
compare it to all of the other binaries I had. Luckily I hadn't recompiled the
binary since copying it and it matched the binary on one of the development
machines that had the binary and sources. Of course it actually had several
versions of the sources, now which were the right sources?

By running the strings command over the binary you can actually find the full
paths of the go sources used.

Finally I have the definitive sources for the version of the tool I hacked
together over 3 years ago and haven't had to touch the source again until now.

I need to stash everything into Git and distribute it to several machine - as
I should have done in the first place[4].

Hold in there Michal and Josh, the changes are going to be made. It's just
going to take me a little longer to implement them! :)

I guess the next journal entry should be about the actual changes being made?

--
Diddymus

  [1] ../../../downloads/index.html

  [2] circa 2010/2011

  [3] circa August 2012, I was actually using the old Perl version for the
      first four months of WolfMUD's resurrection.

  [4] Normally I do, this was a rare exception, honest! ;)


  Up to Main Index                           Up to Journal for October, 2015