Tuesday 30 April 2013

Derp that Programming!


I've just spent the best part of my morning setting up a developer on a project at work, this would go unmarked, except I remember setting the same developer up on the same project about three years ago, and they did produce a module for this project back then... Yet it seemed today that their head was empty...

And I mean, empty... this person, I was telling them to click on things and they were like looking down at their mouse... "A click eh, how..a...ah... Ah I see, the button thing, yes".

I was specific and pretty slow, "plug in the USB device and copy filders x y z off of it".... two hours later.... "have you copied those folders?"... "Ah, no, the USb device has not appeared in the computer list, I've took it out and put it back in again twice"...

I walk over, press F5 and voila, there it is... "Right, I'll get copying now"...

Now, this person is meant to work with me on a tight time scheduled project... I don't hold high hopes.

Monday 29 April 2013

Don't Interface just Encapsulate!

One of the major projects at my place of work came into my sphere of influence recently, and importantly it came to me with no restrictions on what I could do with it.  Unfortunately, so far, all I've been doing is sorting out horrible implementation and code weirdness.  Now, I can't go into specifics, my employer would not thank me, however, I can and intend to document one of the major problems.

This is a problem born out of the project developer - the guy who sat down and thought it up then set his fingers to the keyboard - being out of date, you see this chap has never had a formal introduction to object orientated programming.  He has a semi-idea of the uses of OOP, but he's never really put it into decent practice.

I always knew this, speaking to him at times I with an OOP eye would see things one very clear way, a clarion thought of how the structure of the class hierarchy would, and perhaps should, layout.  However, I would get a dull eyes stare back, something like a dog being shown a card trick.  I've used that statement on this blog before so I won't continue, what I will do is given an example of what I found and removed from one of the most major critical systems.

The system forms a set of classes, each have to contain the same flags and values as the others so they're mutable, but each is a different class.  So, say you have a "Person" and then you have "Staff", "Drivers" and "Servants" derived from them.. You could easily see these as objects.

What I was not expecting was a very strange use of interfaces... So, enough talk, some code, and this is C# folks... I'm sorry!


public interface Person
    {
        string Name
        {
            get;
            set;
        }

        int Age
        {
            get;
            set;
        }
    }

Given this, you can now implement this interface in other classes, and those classes will be forced to use define those elements... Right.  So, this code:

public class Driver : Person
    {
    }


Fails, with the messages: "Error 1 'Driver' does not implement interface member 'Person.Name'" and "Error 2 'Driver' does not implement interface member 'Person.Age'"... And I can see what the chap who wrote this was thinking... It went down something like this... "GREAT, Now everyone trying to use my Person interface is forced to define Name and Age"... And that is what Interfaces are for, but that's not what these classes are used like, what they need is to encapsulate a name and age which are already defined.

In the interface above each and every class has to define the function, but that means there's a copy of the same code being written over and over and over, that's useful if you need those overrides to define different behaviour, but this person class, just like the class in the software I was working on, are used for the same thing each and every time.... This makes repeating the code over and over wasteful, and hard to maintain.

What should have been done is encapsulation, the base class should provide the functionality and then the derived classes just  have it, they inherit it, the base class encapsulates the common functionality and then the derived classes don't have to worry, you've written one set of code for the equivalent of this interface and instead of rewriting it you just put the inherit into your derived class...

class Person
{
     private string m_Name;
     public string Name { get; set; }

     private int m_Age;
     public int Age { get; set; }
}

class Driver : Person
{
}

So, I showed this the chap in question, and  you know what he said... He got quite shirty in fact... "Well I can't stop people just creating instances of the "Person" class, that makes my derived classes pointless!"

Oh yeah buddy, let me show you the way...

class Person
{
     private string m_Name;
     public string Name { get; set; }

     private int m_Age;
     public int Age { get; set; }

     private Person () { }
}

class Driver : Person
{
}

With a private constructor now no-one can create the Person class itself - create private copy & move constructors too for good measure!

The silence which ensued was palpable, about twenty minutes later, after staring and staring the guy came back with this:

class A
{
    private string m_Value;
    public string Value { get; set; }

    private A () { }
}

class B : A
{
}

B bInstance = new B();

"Right, now I got that, but Value is undefined in B, I need it to have a default value"... I swear to you now, I stared past his left shoulder and just shivered as I did this for him:

class A
{
    private string m_Value = string.Empty;
    public string Value { get; set; }

    private A () { }
}

class B : A
{
}

B bInstance = new B();

"No no" he screamed with glee, giggling, "I mean a value so I know its a B!" or whatever, so I did this:

class A
{
    private string m_Value;
    public string Value { get; set; }

    protected A (string p_Value)
    {
        m_Value = p_Value;
    }
}

class B : A
{
    private static readonly string c_Name = "BValue";

    public B ()
       :
       base(c_Name)
    {
    }
}

The silence was all encompassing by now, and I left him to it.  I had by the end of my programming session - before I went for my afternoon break - created around 12 versions of his derived class from the new base and totally removed his interfaces which were so ugly.  I don't think he'll forgive me, but the code was a lot smaller and easier to read, and in my opinion more correct.

The only reason the chap did not get to the same conclusion as me was a lack of understanding of the object model & hierarchy, a professional programmer foxed by this, and a more senior programmer than me... Really makes me wonder why I'm earning so little!

Thursday 25 April 2013

WarThunder Economy Still Broken

Last night I had an interesting time playing WarThunder, I did write a post to this effect earlier, but its gone missing.  But I made Rank 11 with the help of some large slices of XP (300,000 worth from an achievement) but made little to no cash... I think I went from approx 680,000 lions to just over 700,000 earned in over 10 flights... So, 20K, in ten fights that's an average of 2K per flight and that matches my recollection pretty easily.

However, I just happened to wonder into the WarThunder forums and into the 1.29 update, and I noticed the image used by the "Borisych" member of the team... The image is:

You can go check this yourself here.

But, before you do, do you recognise the image?  Its from the film Snatch, the actor is one Alan Ford playing the part of "Brick Tip".  At this point in the film he strolls into the pawn shop, which is covered in dead body and after receiving that cup of tea from his body guard explains he is an 'orrible cunt.

Well, Borisych, of the WarThunder team, with the state of the lion earning ability of your once great game, yes, yes you are a cunt.  Well done.

Wednesday 24 April 2013

Check your English


I've spent a serious amount of my morning explaining to people that my software was working fine, and there was in fact a hardware error.  All to no avail, as it seems the first report of the problems was worded badly and not in my favour.

"We were having the problem with the XXXX not working on Xelous's Test App.

This morning I turned off the power, re-seated the board and they’re now working."

So, with my software unchanged, they played about with the hardware and voila it magically works... This is not a software problem, but its worded just enough as to inflect that there was a problem with it "not working" in my application.

Now, you can take a look at the time of my blog post last night/this morning and see I was working on this all night and fixed it... So to see this report this morning annoys the shit out of me, no-one else was working at gone 1am, no-one else gave a shit, but suddenly they're all experts and pontificating about the problems "in the code"... It was a fucking hardware problem!

Hating it today, proper hating it.

Corrupting my Heap

I've had a hell of a few days, the family thing has droned on, but I'm fast washing my hands of the situation - they can go masturbate in their own mess as far as I'm concerned, this makes the wife and I the bad guys, but logic will one day prevail, most likely when my mother can't interrupt people and pontificate utter bollocks in her rude manner.

Anyway, what about this Heap Corruption?  Well, what a debugging session I've just had, it lasted nearly 3 hours - that's a long one for me - especially with my C++ code.  That's not to be big headed, but I have evolved my coding style and used the libraries (boost & std) in the manner I do without issues all the time, so to suddenly find a bug - one corrupting the heap - was a bit of a nasty sting.

I can't go into specifics, due to the nature of the work I was carrying out for my employer, but here's the gist...

A function was bound with boost::bind... And was called back from another location in the code at regular & mutually exclusive intervals, so on a timer... Here's pseudo code:

#include <memory>
#include "TimerFoo.h"

using namespace std;

void baa (const bool& p_Error, const bool& p_Cancelled)
{
   if ( ! p_Error && !p_Cancelled )
   {
      // DO SOMETHING
   }
}

unique_ptr<Timer> l_MyTimer = unique_ptr<Timer>(new Timer(boost::bind(&baa, this, _1, _2)));
l_MyTimer->Start(5000);

Right, and after waiting the 5 seconds the baa function would be called, and suddenly my application would crash horribly, inside the boost libraries.  Either in the function pointer headers, or even in the unique pointer header of the std.  It was an utter mess.

And the call stack gave no clues about the problem, it neither helped workout quite what had run.

The problem turned out to be a problem inside the "DO SOMETHING", which was calling into the psapi and trying to use the TCHAR pointer somewhere incorrectly.  I removed that code and its all fine again - but so scary a crash.

It has spurred me to want to update my personal coding standards and include the rule "If you have a boost::bind bound function, and suddenly your code crashes, rem out that function's body and re-run".  This is essentially how I found the above bug, I removed the whole guts of the callback and voila the code ran, but with the heap corruption it was hard, nigh impossible, to see what had actually gone wrong.

Wednesday 17 April 2013

Annoying Family


Some things in life are bad,
They can really make you mad,
Other things just make you swear and curse,
When you chewing on life's gristle,
Don't grumble give a whistle,
And this'll Help things turn out for the best....

Sage and wise words there, but I'm sat in the office and after a whole morning of base code frustrations causing me to be mad, I've just been on the phone to my Mother.

Now, those of you whom don't know my Mother let me paint a picture, she's broadly the same character as Hyacinth Bucket from the TV Show Keeping Up Appearances  she talks incessantly AT you, not to you, not with you, AT you.  She's highly opinionated to a fault - worse than me - she taught me how to hold an opinion to the point of fault and be stubborn, but she's far worse.  And true story, we once went on Holiday and when we came home British Telecom had sent a letter to query whether the rented phone we had was out of service, because there had been unusual activity on our line.  The unusual activity was there not being any calls made... So there's the scene, a talker, right, she's a talker.

So it was with amazement that today - just a few minutes ago - I get a text "Call home now"... I call... and I'm informed that my Nan has been rushed to A&E - not very well at all she's not... Okay, right... News, information on the fly.

"Oh, and I'm having a major operation tomorrow"... First I'd heard of it, first mention... "I was going to tell you when you last came around".... The last time I went to their house was two months ago... two months, sixty days... Sixty days where there could have been a text, sixty days where there could have been a phone call, no, sixty days of silence.

From Britain's most talkative person!  Silence.

This is all part of the games my mother plays, she plays Chinese whispers back and forth, she plays about with people, she'll say one thing to one person and then withhold it from another and see when she has that whisper come back to her, she does it to pull the strings and ride the grape vine, and she does it because she's basically retired from work and loves to talk, but always wants to feel the epicentre of life.  When really she's just one person, with one person's story, and she's a minor footnote on very few peoples radar.

And so, to withhold this information from me, her eldest son - appears my younger brother knew all along - was part of her shenanigans and games of whispers.  As Robert Jordon describes it in Wheel of Time - She's playing "the Grand Game"; but instead of their being a crown, fortune of kingdom on the line there's just a few poultry facts which needed to be passed out to include other people.

I find this so frustrating, annoying and I wish I could sit and chew on it, but I'm so tired of this bullshit approach, so tired of the whispers and deceit, because that's what it is, its like she withholds things to taut back to you "you didn't know I've been shopping"... I don't care you've been shopping, and you didn't even tell me... its so trivial.. but "I'm having an operation, and you didn't know I'm having an operation"... Erm... I'd have liked to have known, and liked to have been told...

I know for a fact that her inner circle of supplicants knew all about this situation, its only me, the only person who out strips her in the family (for intellect) whom has been kept in the dark.  Because I'm very pragmatic... "oh you're ill, can they fix it?  Good, go get it fixed"... That's my style, and this whole thing is silly its about a problem she had 20 years ago, and never tackled... 20 years is well enough time!  Not least because she can't claim "the kids stopped me"... we left home over 18 years ago... I've now been gone from home longer than I lived there by a fair few years, but she still wants to pull the strings, and this whole episode is here trying it.

Also about my Nan being in A&E... I work right next to the A&E unit, I can see it out the office window... My mother will be in an operation tomorrow... But she's put herself down as primary contact... she'll be miles away in an operation in another hospital... I'm 500 yards away from Nan and available... but Oh no, I can't take that call, I can't sort that out... because that would be my mother ceding control and she can't bare to think of not ruling the roost

Annoying, annoying, annoying fuckers my family are.

Friday 12 April 2013


Today I've been looking at a C++ problem, well when I say problem, I think there are no problems you can't work around in C++, but this particular problem relies on someone spotting a compiler error and acting correctly.

The trouble I have is that the compiler error is pretty obscure - this I will admit as a problem with C++ compilers in general - and that the error really has no meaning in the context of the solution I am trying to make the programmer come to.

Let me explain with a little code, I have a class a base class in fact, we'll call this A, and this class has a constant inside, lets say the "Name"... Now we don't want the base class to define a value for this constant we just want it to make all classes which derive from it realise they must define a value for this constant... So the code might look like this;

#include <string>

using namespace std;

class A
{
public:
static const string c_Name;
};

Now, normally here we'd then have:

const string A::c_Name ("DefaultValue");

And if we did nothing untoward would happen at this point, the derived classes could all use c_Name, just it would have only this default value, and the static instance of c_Name in one derived class would NOT be the same string as in another class, they are separate values... so there's no problems.

class B : public A
{
};

Now this derived class has a c_Name, but its "DefaultValue", so you would expect to just define a new instance:

const string B::c_Name ("New Value For Constant");

Unfortunately, this is totally wrong, because the new definition of the constant in B causes a redefinition of the constant in the base class, and multiple initization is not allowed.

So, we remove the default value...

#include <string>

using namespace std;

class A
{
public:
static const string c_Name;
};

//const string A::c_Name ("DefaultValue");

class B : public A
{
};

const string B::c_Name ("New Value For Constant");

And everything now compiles, there's no problem... Except that the base class does not provide a default name, so we're relying on the programmer to spot when they miss the definition of name and not assume they've got to define it in the base class and so stop our intended operation...

But the compiler error is horrible... lets take a look at it from Visual Studio 2010:

"error LNK2001: unresolved external symbol" and then the hell that is the output... 



The error makes sense, we've defined a static in the base class and not defined it anywhere, my problem is how do I educate a programmer - whom will most likely not read my documentation - to NOT define one in the base and so break hundreds of classes in the future - but know to define it in the class they just wrote and give it a meaningful name?

Thursday 11 April 2013

WarThunder - Players Can See the Imbalance

I have to commend the WarThunder content crew for releasing more Historical Battles - my favourite way to fly - however, the imbalance in the different air forces is becoming especially annoying and prevalent.

Now, the Japs, I love my Japs but I'm yet to get a proper zero - I have the floating zero - but not a real one the reason being the god damn grind to gain the lions to buy it and as I'm already posted I'm not willing to grind.  But also the Jap planes are really the proverbial "Glass Cannons", but firepower and no amour - yet this is really real - as other posters & players say all the time - but in real-life the zero could out maneuver everything flying against it, and they can't in arcade and can't well even in Historical Battles in WarThunder - so they're unbalanced.

And because they're unbalanced players avoid wasting their precious time trying to play against over powered - or just balanced - emenies, take a look at this, this is a screen shot fresh of the press a few minutes ago, see the numbers in the queue....


There are two historical battles... Japs v Yanks - WoW there are a lot of Yanks waiting to fly!... And then Brits v Krouts - and oh mamma how many Luftwaffe jockeys are there in the queue?



This is screaming out about the imbalances, the Japs can's survive so the yank tear them up, plus the yanks have strapped a bomb capability to nearly every plane and a billion machine guns to every bomber, so they're being played and earning rich rewards.

The Germans they appear to be being played; through personal experience on the receiving end; because their fighters tear the British planes out the skies - I commented in game to other players about this to hear resounding replies that I was indeed correct - the Brits simply fall out the sky.

Now, Jingles over on YouTube posted his heroic Lancaster flight earlier today, and he shows a surviving bomber - well surviving ish - but this is rarely the case I've been out in Blenheims, Beauforts, Beaufighters and Wellingtons and always been hacked out the sky by well flown 109's.

You can't knock the 109 pilots they're doing things right, but they're only being quite so successful because of this perceived imbalance - I know I'm not a terrible bomber pilot, and I know I'm not an awful fighter jock but me just saying the obvious is not enough, so evidence, check out the numbers in the queues, check them out yourselves....

And you wait, you wait for a Russian Historical battle, there'll be hundreds in those queues as the Russian planes are all pretty much INVINCIBLE.

Wednesday 10 April 2013

Work - Feeling Shit & Resurrecting Systems

I already said I feel like shit, well I soldiered through Monday and went home, but it was clear it was a total struggle, and come Monday night I was suffering, could not see - eyes streaming - could not even close them to sleep and then even when I did sleep I kept sneezing myself awake, so Tuesday was a no show, and nor was today I gave myself the day to recover a little more, I feel very much better now - I'm probably awfully contagious, but hey ho.

Right now I've got a sore nose and sore eyes, I've got a chesty cough and that heavy feeling in the center of my chest, that heavy feeling of a threatening chest infection.

So, today I was blissfully tucked up in bed, when the wife came back in from popping to her parents, and she was all panicking, she was handing me her phone, "Your work has been calling me!!!"

Mystery, her number is down as my emergency number, my own mobile is down as my own contact; checking it, its dead of battery, I've not charged it since last week the poor thing.

Anyway, I take the wife's phone from her, blow my nose take a swig of juice and call work, the main reception have no idea who is after me, the manager present in the support department - who is the most likely person to want me - has no idea who wants me, and I had already called into HR that morning, so... Mystery, no-one knew who wanted me.

An hour later HR call me, the big boss wants me, or rather one of the trio of big bosses wants me, there's an emergency project needs consulting on, its stuff only myself or my direct manager can advise on, my direct manager has been signed off work himself for over two months, so they're hoping to god I'm not going to be off long.  I reassure them telling them I'll be in tomorrow, and go back to rest.

But, then I'm mulling over, what is this work, what is the big need... I also got thinking about something else...

There's a certain other person in our department, a person whom volunteers them self to do all the strange things - such as be interim server manager - or chief communications technologist - and they're off and people sit with their thumbs up their ass not wanting to call them, or if they do call them they get answer phone and ignored.... I'm off one day... ONE FUCKING DAY... and suddenly they had to get me, they called not just my battery flattened phone, but my emergency contact's number too...

THEY NEVER CALL THIS OTHER GUY... Now, I'd be flattered, I'd think whoa, maybe I'm needed and valued and getting a little respect in my role - after a decade - but no, I think they just know I'm not going to go mental - like the other guy would - and so the boss guy got them to call me up and check when I was going to be in.

Anyway, whether I'm wanted or not, I've today set about sorting both the snuffly mess that is my head, and my software files... The problem being I've had both my main desktop machine out of action for nearly 5 months with no power supply! And I can't afford a new one - and I've had my laptop tip over with a hard drive fault just last month, so I've precariously had little backup storage and replication of my files in nearly 3 months.

Not to mention some of my files are on Virtual Machines which I hold only one copy of, or the files have not been backed up at all.... A situation which I have to remedy today, and so I've set about taking a copy of the virtual machines from one external hard drive onto another, then a copy again to use for development on my repaired laptop.

Three copies down - over 400GB a piece - that's been a good 43 minutes all around.

I've now got to look at my code back up server - its a linux machine - which has been left untouched since the main desktop PC went on the fritz, its served by a really nice 100GBit switch into my LAN, but because I used the desktop PC as a gateway for it out onto my wireless I've simply not been able to fire it up, so I'm possibly going to fit a wireless card to it, get it connected wirelessly - slow as that is - and give it updates whilst I get the virtual machines working on my laptop and then connect it to the 100GBit switch directly with a wire and we can rock and or roll.

Monday 8 April 2013

Man Flu

I feel thoroughly drubbed over, I'm sat at work right now, staring at lines of code wondering why the fuck am I here.  The reason for this isn't some deep mid-life crisis, its not some in-fathomable coding glitch either, its the simple fact that I've got a cold.

In Britain, and I guess elsewhere, when a man has a cold he gets short sharp shrift as regards sympathy... "You'll find sympathy in the dictionary somewhere between Shit and Syphilis" as the saying goes.  But also here in Britain there's this rule of not bringing illness to your work colleagues.

So this morning I phoned in to HR and said, "I've got a stinking cold, I can come in, but I'll give it everyone, what do you want?"... They told me to come in.

There we go, here I am, and I've now been to the kitchenette - good luck anyone touching the taps, the coffee machine or the water cooler!  I did wash my hands, but still, good luck.  I'm also coughing and sneezing over my desk - so anyone wanting a document off me is going to get a short barrel of snot.

Consequently, because I was ill, I spent most of yesterday in bed - or being made to do things by the wife - whom would not let me rest...

So I missed this:



This is the second "offer" from them I've missed, I missed out on the gold for fights the other week, and I missed out on this, the reason being illness, but also the current economy has left me feeling lack lustre towards playing at all, its too costly to play the game at the tier I have access to.

I've effectively stopped playing, until they fix the economy there, but its cutting my nose off to spite my face, I would clearly have liked 24 hours of premium.... maybe not yesterday as I was so ill.

Thursday 4 April 2013

RIP - Lucas Arts

Sad news, Disney takes its dead rattle to Lucas Arts, the only part of Lucas film to deliver decent Star Wars content to us since its founding - that's not to say they didn't deliver a turd now and then, but they gave us great content more often than not.


I'm so sad to see the company be thrown away like this, not least because Star Wars 1313 looked to be a decent title.

Now they'll license the brand out and who knows where this might end.... "The Empire on Ice" perhaps?

Read the story as it breaks here: http://www.bbc.co.uk/newsbeat/22025391

Tuesday 2 April 2013

E-mail Hacked, WarThunder Ruins Economy & Minecraft restart


What a bit of a roller coaster time I've been having, lots of personal stuff, but then technology has slowly crept back into me.

I'm still enjoying WarThunder - though less so with the currently fucked economic model (I have Spitfire Vb and Vc, as well as two differnet model 109's to buy - all for 100,000 credits, whilst only able to earn about 10,000 per game, this means I'm going to take about 50 games to earn the cash -  and I only get to play 2-3 games an evening, so this is over a months grind to just play the next level of aircraft) and to be honest I can do without a grind of a game.

They did a good job with the April Fools joke in game however - I did enjoy flying in the My Little Pony Airforce, and the artwork was top notch, however I'd have been happier to see an economy fix.

Also, there was an event on Sunday where for winning your first and fifth fight you'd get gold eagles, I never saw this advertised, I never understood the text in game, and I never won in the one game I played that evening, so I never got any gold eagles and this makes me sad, from such PR highs to lows all in the space of a weekend.

The other technology news was that one of my e-mail addresses was hacked, by a chap in India, whom I thoroughly intend to visit and castrate.  Seems he trawled and then trolled my Yahoo e-mail password and started to spam people in my address list at 3am.  The next morning my wife asked "Why were you up at 3am sending me this"... and of course she'd clicked the fucking link, so I had to wipe the laptop, and change my yahoo account and all manner of things.  But being in possession of an ounce of technical nouse I fired  up a virtual machine and tracked this link mailed around down, I also tracked the links in the dozens of failed mail daemon delivery messages spammed from my account.  And they all went back to an educational establishment in the Punjab.

I sent a mail to the administrator of said Educational Establishment, but I don't hold much hope of them cracking down on this shit, not least because this place in the Punjab appears to be a rocky stoney mountain when you look on Google earth, but the image of the site as shown on their web page looks like a none-descript office building from Droitwich - no offence to Droitwich.

The other thing that's been going on is Minecraft - I've had minecraft since it first came out - I've even studied the java code under the hood - yes I'm that much of a geek.  But I've only really played it once.

I started to play it again - mostly as I'm so agreeved at WarThunder - but also because I'm still without power on my main gaming PC so wanted something I can run on the laptop whilst on battery power.

Anyway, I've started to enjoy Minecraft some, I have a little railway, I've got a cow farm, and I'm starting to automate somethings with the seemingly magic redstone.  I've been to the nether and I plan to open a big mining facility to discover more diamonds.  But I'm also tempted to start to record my exploits, and make a series of progress videos.  IJevin on YouTube does a good job of this, but he does seem to appear with lots of gear start off the bat, I'd rather show everything in real-time - or at least sped up in places - to show every rock, every seed, every stick gathered and how it came along.  But this is a pipe dream, I don't have a voice for YouTube video commentary, and I don't have the time, though I've love to have more YouTube content.