Monday 28 October 2019

Beachy head marathon

This years marathon has to be the hardest one I've ever had to do, sadly it was also the least enjoyable but that is no fault on the course at all.

My compaany in their infinite wisdom has decided to change location from the nicely accesible town of Uckfield to the not so nicely accessible but nicer when you get there town of Lewes.  I would love the move to Lewes if it were not for the drive on the A27 which so far regularly takes well over an hour, and I am only on it for 12 miles - I can almost run this fast!

Anyway, how is this relevant to my marathon tale, well in Uckfield there was a gym not far from the office that I could easily get to in my lunch break and hey presto could keep my fitness at a certain level, not fully trained, just at a level that should I need to train for a marathon it would take little more than a fortnight.  In Lewes there's no such option, thus leaving me with no way to remain fit and stupidly I didn't take this into account.  At the last minute 2 weeks before the marathon I decided to do a small dress rehersal since it's the first time I would be running with my new back pack, this was a lesson learnt earlier that drinks stations never seem to be there when you need them so taking your own fluids is really useful, most people opt for a £100+ camel pack, I opt for a £10 Aldi/Lidl special since they both offer the same functionality when you get down to it and the last Aldi one has lasted 7 years with regular use as my running/cycling bag as well as family outing pack!  The half marathon distance I did revealed a few aches so I decided then and there that I wasn't even going to attempt to get under even 5 hours, what's the point, I am older and wiser I don't hurt myself when running anymore I am just proving that I can do the distance not that I can do it quickly - tbh even walking it is an option.

That trainging run was in a light drizzle and everything was fine, in fact I used very little water so considered not taking so much with me, glad I changed my mind on the day!

Race day came and I'd forgotten to get myself a mars bar or a bottle of lucozade which I tend to carry just in case, ooops.  The start was really quite hot, and very very crowded I don't remember it being so crowded before but this is the first time I started so far to the back of the grid.

After the start was signalled it took 3 minutes for me to reach the start line, I had no idea I'd started that far back, but at this point I noticed that even though I was only walking I was sweating buckets, I could practically ring my hat out so I took it off to keep cool.  I thought at the time that it was more than just the weather making me sweat but carried on regardless.

I knew I wasn't fit and ready so had already resigned myself to a gentle jog around the course and that's precisely what I did.  One thing I did notice at the back is that people are far more chatty and there was a greater sense of camaraderie than where I normally start.  This year there seemed to be an incredible amount of queuing, at the footbridge into Alfriston (I think) for example around the 15Km mark I had to wait for about 8 minutes to get on the bridge.  The reason for this was clear though, the route that was normally taken into the village was under several feet of water, I've not seen anything like it before.

At roughly halfway I knew I wasn't quite right, but also knew my dad would be finishing the 10K run so wanted to see how he was feeling so stopped to make a phone call (11:50am).  I was definately not right at this point as when I went to leave a voicemail I started to choke emmotionally and the only other time this has happened is when I did the Brighton half when I had the flu - which is a very stupid thing to do I couldn't ever recommend it! - I pressed on and around halfway my muscles were good, my breathing was good my bones were good bbbuuuutttt I felt like crap so basically decided to walk the half I had left.

From this moment on I did very little running, I occasionally jogged downhill and along the flat but most definately walked the rest.

The support was fantastic, I was amazed that so many people showed up in the wind and rain to offer moral support, sweet, oranges and alsorts.  One lady I think in Jevington had the boot of her car open and it was like the school tuck shop I cannot thank these supporters enough.  Before I forget I can't thank the St. John Ambulance enough either as the day before I'd been on a very good first aid course and now I was seeing them out on the hillside ready for action!

Litlington was once again my favourite stop (13:02), for anyone that starts the marathon but retires before they get here I suggest they give it another go because once you reach Litlington the support, the live music, sausage rolls and drinks are enough to see you skip the last 10 miles home :)

OK so I didn't skip home I did continue to walk but Litlington does make facing those steps out of the forest a little less daunting.

I got to the top of the hill just before the decent into Cuckmere and OMG the lovely ox bow river was gone!  Where there used to be a lovely winding river was now a single wide open lake with the odd sprig of grass poking through the waters surface with a kite surfer skimming over the top, I had no idea the flooding had been so bad.

Anyway this part of the course always marks the bit I struggle to run even when I feeling fit, these first two hills always tire me out the most, but you do get a lovely view at the top,not that I got any where near the edge this time as the wind was far too strong, in fact the ascent to the beachy head pub was at times assisted by the wind!

I met some lovely ladies running for a variety of charities on the beachy head stretch and they reminded me that we'd had a chat many miles previously and they'd been trying to catch me up ever since, such is the uncompetative nature of the event the helped cheer me up and push me on :)

Finished around 15:50 but not 100% sure and haven't had my official time yet but guess it must be around the 7 hour mark, a good 2 hours longer than ever before :O

I suppose one of the strangest things was that someone got married half way round, what was more strange is that whenever I saw the happy couple running they weren't actually together which seems a bit weird as I'd want to stick with my wife on our wedding day, then again I wouldn't want to do a marathon on my wedding day either :)





Thursday 4 April 2019

Can we please stop using switch most of the time

I am not talking about a light switch here
Allow me to elaborate, the switch statement I am referring to is in Java, it is the same switch statement you will have seen in C (or B for that matter if you're old enough).

The switch statement is a very simple representation of an indirection vector table we've all seen it for example
String reportNumBytes(int size, int modifier) {
  switch(modifier) {
    case 0:
        return String.valueOf(size);
        break;
    case 1:
        return String.valueOf(size/1000) + " K";
        break;
    case 2:
        return String.valueOf(size/1000000) + " M";
        break;
  }
  return String.valueOf(size);
} 
There are many things wrong with this code, the arguments aren't final, the method name is poor the modifier is a cause for magical numbers to be used, there are multiple return points but the main point is it uses a switch statement. Also try not to get too hung up on the fact that I am dividing by decimal devisors rather than binary divisors, this is largely irrelevant for the discussion and I don't want to get involved in the endless KB KiB debate. Let's remove the noise items from this list first
enum SizeModifier {
    BYTE, KILOBYTE, MEGABYTE;
}

public String reportNumberOfBytesUsingModifier(final int size, final SizeModifier modifier) {
  String result = String.valueOf(size);
  switch(modifier) {
    case BYTE:
        result = String.valueOf(size);
        break;
    case KILOBYTE:
        result = String.valueOf(size/1000) + " K";
        break;
    case MEGABYTE:
        result = String.valueOf(size/1000000) + " M";
        break;
  }
  return result;
} 
Now we can remove the magic numbers, or rather we can move them to the enum and it all begins to look far better.
enum SizeModifier {
    BYTE( 1, ''), 
    KILOBYTE( 1000, 'K' ), 
    MEGABYTE( 1000000, 'M' );
    final int divisor;
    final char identifier;
    SizeModifier(final int d, final char id) {
        divisor = d;
        identifier = id;
    }
    String toShortHand(final int size) {
        return String.format( "%d %s", size/divisor, identifier );
    }
}

public String reportNumberOfBytesUsingModifier(final int size, final SizeModifier modifier) {
  return modifier.toShortHand( size );
} 
Of course I do still rather like the creation of a command dictionary :) but...
private Map> commands;
...
commands.put( "byte", (v) -> return String.valueOf( v );
commands.put( "kilobyte", (v) -> return String.format( "%d %s", v/1000, "" ) );
commands.put( "megabyte", (v) -> return String.format( "%d %s", v/1000000, "" ) );

public String reportNumberOfBytesUsingModifier(final int size, final String modifier) {
  return commands.getOrDefault( modifier.toLowerCase(), (v) -> return String.valueOf( v ) ).call( size );
} 
in this instance I think it makes it less readable

Why clever people are dumb

why are smart people dumb?

There's someone that I know is a very clever person, at least they're very clever within the confines of their chosen academic area, however he displays so many right wing views that it has led me to reconsider my current understanding of people.

I have never understood why people believe in things that are proven to be wrong by the facts that surround them.  One such undeniable truth is that countries that don't allow guns simply have fewer gun related deaths.  It isn't even a question of corrolation vs causation you need only look to Australia for evidence of that one gun crime high, then they ban guns, gun crime drops play around with the figures all you like that's the basic run of things.

So a very clever person believes that "my safe place is where my gun is" that oh so brilliant stroke of genius spoken by the NRA.  Just take a look at the statistics of the number of people killed by their own weapons to know this is a silly statement to make.

Look at the source, the NRA, an organisations whos power is derived from gun sales, is promoting the ownership of guns well durrrr.  A business is in the business of making money and the NRA's mission is to keep power.  I must admit they're very clever, they've managed to alter the wording of a text otherwise considered to be of almost religious content the US constitution so that "A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed." simply ignores the bit about 'a well regulated militia' because it doesn't suit their puspose.

The clergy are responsible for a very similar thing, that time it was to keep the lower classes under control because after all they far outnumber the people in charge, as long as they don't realise that fact they'll never be in danger of an uprising.

Both the NRA and religious organisations have done their job so well that the people they seek to keep inprisoned within invisible bars of belief are the very people that defend the ideals they've been given by the bodies in power to the death believing them to be beliefs of their own reconing, if it wasn't such a sorry state of affairs it would be comical.
 
Stack Overflow profile for Richard Johnson at Stack Overflow, Q&A for professional and enthusiast programmers