Wednesday 26 September 2012

Software Engineers Never Get a Specification.... Deal with it!


As a software engineer, I'd love to get specifications for the software people want me to write for them.  Unfortunately in this world of mobile wizardry and the eponymous "Apps", people don't want to sit down and help specify what they want, they want to just give general ideas of what they want and they believe I'm able to discern everything else for myself.

This one-sided "just do it will you" attitude has forced me to turn the tides on people, in the last three projects I've worked on I've been left to do what I wanted from start to end and then had numerous, onerous, tiresome complaints that what I've delivered (though good) wasn't quite what they wanted... I've politely, and not so politely, pointed out that if they don't actually feedback, or even start off, with a good idea what they want.  And if they work with different goals than I work with, and both they and I see the interaction with the end customer differently, then even though we work for the same company we can't reach the same conclusions nor attain the same common goals.

All for naught however, as it always just seems to circle back around to "its your job to create this software, get it done"... my whimpers asking them to define "this" go unheeded repeatedly.

So, the worm has turned, I've today released an internal tech demo of a new software element, its just one element of a three part series, and this is only a mock up of it... The challenge is to get a "feel" for user interaction on a display.

We have a touch screen, we have graphics... But we have no idea actually how people interact with our system... We don't do time and motion studies, we don't even sit in the distribution point and watch, we just sit and assume people would interact with the machine how we would... And they don't.

There's nothing ground breaking about this piece of software, nor my releasing it... what's revolutionary and what's pissing those who should have spent some time specifying how it works to me off is that... Everything in it, EVERYTHING, is configurable through an XML file...

The margin width, the speed of the touch screen, the area of the images, the images themselves... Everything on this thing is configurable... So its really all up to them to decide if how it acts is how they want it to, they can turn up the deceleration, turn up the touch response, tone down the area a finger on the screen represents... they can mould and fold this configuration around all they want.

The upshot has been two fold.. Firstly, and brilliantly, for the first time ever I'm getting meaningful feedback on the behaviour, I'm even getting told that some metric is missing, or some feature needs representing and what range it needs to support!

The second fold is not so good... The less able members of staff, that is those whom like to criticise, are taking their analysis to a whole new, abstract, level... Instead of doing what was asked, i.e. to try the application, which is a mock up, out... They're opening task manager and monitoring how much CPU it takes and looking at aspects of it totally unrelated to the idea of "give it a try"... things which are NOTHING to do with interacting with the application... And when I say "This is a mock up, just tell me how you think it feels, I need that human feedback of how it works, how it comes together"... they reply... "It comes together as taking 20% more CPU than we can allow"... That's not human feedback, that's not how it interacts... That's in fact got sweet FA to do with the task at hand.

And I'm starting to file these latter people into the unhelpful bin within my minds eye...

Tuesday 25 September 2012

Coding Standards - Naming Variables


Warning, when you have code and within that code are elements you are naming thus:

        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.GroupBox groupBox1;


You need to stop, look and think... You may know that "Label1" is for the stock inventory level, you may know Panel 1 is the background... You may know this for days, weeks or months... But over time you will forget, its not important enough to you to name them properly, so its not important enough you remember what they do... And this is a downward coding spiral.

Its much better from the offing to spend seconds to give them a meaningful and purposeful name upon creation, so that you can identify them easily from crash reports, or designs, or just people plain old pointing at them in the future... And its the future thats more important, because remember it may not be you coming back to revisit or maintain code later.

Some poor schmuck finding this kind of naming and poor form will as soon as anything point the finger of blame at you, to cast your name as mud and to deride all your efforts; whether warranted or not; as useless trash.

So, don't look a fool, don't be a fool, name things in your code properly... Gui elements, Locals, Members, Globals and Constants they are the currency of your program, so pay them some respect.

Friday 21 September 2012

Twenty Seven


I'm beginning to believe there's something special about the number twenty seven... I've just been into the listing of my blog posts, and on the first page of listed posts, several (that is more than one, less than all) of them have exactly twenty seven views... This would be unremarkable if I had 27 followers, or had 27 friends... But I don't... And I don't...

The posts are seemingly unrelated too, the internet in its infinite wisdom has seemingly guided 27 random people to several random posts on this back end of the world blog of mine... Go figure.

Wednesday 19 September 2012

OpenGL - Gaps between Triangles


A strange problem posed itself to me in Linux last night, infact in OpenGL in general - this problem happened on OSX, Ubuntu, Fedora and Windows Vista for me... Here's the low down...

I've created a simple 3D view contained area in OpenGL



Into this I want to place items, buildings, people whatever... So, I start to define a rectangle, which is going to be a wall...



As you can see, on it I place my text texture, so I can tell left (red) from right (blue) and top (yellow) from bottom (white) to make sure my texture loading and texture coords are correct... But I can see that damn line between the two triangles... Yet I'm using the same vertices for the corners, there should be no gap.

Switching from glBegin(GL_TRIANGLES) to glBegin(GL_QUADS) I can still see a single line between the triangles, so its not my coordinates or triangles... What the heck can it be?

Now, I'm using pretty old OpenGL here, really really old stuff, so for 2012 the information available on the ground is pretty slim, there's alsorts of suggestions out there and no real documentation as to what is causing this...

In desparation I started to play about with the blending settings, to no avail, then I started to play with the smoothing mode:

glEnable(GL_SMOOTH);

glHint(GL_POLYGON_SMOOTH, GL_NICEST);

glEnable(GL_POLYGON_SMOOTH);

glShadeModel(GL_SMOOTH);

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

None of this seemed to work... So I started to play with the multi-sampling...

glEnable(GL_MULTISAMPLE_ARB);

Still no joy....

But.. Disable the smoothing AND enable the multisampling and everything starts to work:



// Set Rendering smoothing
//glEnable(GL_SMOOTH);
//glHint(GL_POLYGON_SMOOTH, GL_NICEST);
//glEnable(GL_POLYGON_SMOOTH);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_MULTISAMPLE_ARB);

I can now start to add brick textures and make my boxes into buildings...


RAII - Please for the love of god....


I'm going to just vent here folks... In programming, if you have a class which HAS TO HAVE all its members initialised, DO NOT just expose an empty constructor...

Here's what I mean...

#include <string>
using namespace std;

class A
{
   public:
   
      int _id;
      string _name;      
      
      A (const int& id, const string& name)
        :
        _id(id),
        _name(name)
      {
      }          

};

There's a class right, one assumes there's only one way to initialise a copy of this class?  The constructor giving implicite values, yes?... Good.

So when you want this pattern, make sure it works just how you expect, hide the other constructors... thus:

#include <string>
using namespace std;

class A
{
   private:
   
      A() {}

   public:
   
      int _id;
      string _name;      
      
      A (const int& id, const string& name)
        :
        _id(id),
        _name(name)
      {
      }          

};

This stops blank copies being generated, on compilers which automatically create the defautl constructor public!

Likewise in C#, do the same... If you have a data class:

class B
{
    public int _id { get; set; }
    public string _name { get; set; }
    
    public B ()
    {
    }
    
    public B (int id, string name)    
    {
    _id = id;
    _name = name;    
    }
    
    public string NewToString ()
    {
    return string.Format("{0}-{1}", _id, _name);
    }
    
}

That class is no big deal, the int and string are implicit values, they have inplicit values upon creation.

B b = new B();
Console.writeline (b.NewToString());

All works fine, but if we add a user class in there, or any other class which can be null... then we have to be more careful...

class StudentRecord
{
    public string _name { get; set; }
    public DateTime _dob { get; set; }
}

class B
{
    public int _id { get; set; }
    private StudentRecord _student;
    public string _name 
    {
    get { _student._name; }
    set { _student._name = value; }
    }
    
    public B ()
    {
    }
    
    public B (int id, string name)    
    {
    _id = id;
    _student = new StudentRecord();
    _name = name;    
    }
    
    public string NewToString ()
    {
    return string.Format("{0}-{1}", _id, _name);
    }
    
}

What happens now?.... Well the code will crash:

B b = new B();
Console.writeline (b.NewToString());

Will throw a null reference exception in the call _name against _student, as it is not implicitely defined during creation when using the default constructor.

What we should really do is utilise the "Resource Allocation Is Initialisation" (RAII) concept and only allow a new B to be created with the defined values.  And we should do this to all classes, whether they have implicit values or user defined classes within.

How do we do this?  By stopping the default constructor being used:

class B
{
    public int _id { get; set; }
    private StudentRecord _student;
    public string _name 
    {
    get { _student._name; }
    set { _student._name = value; }
    }
    
    private B ()
    {
    }
    
    public B (int id, string name)    
    {
    _id = id;
    _student = new StudentRecord();
    _name = name;    
    }
    
    public string NewToString ()
    {
    return string.Format("{0}-{1}", _id, _name);
    }
    
}

Now, the only way for the programmer to get using this wrong is to mess about with the code!

It stops all those annoying "What the Hell just happened" during runtime, and some poor other schmuck doesn't have to do running around working out where your code went wrong because it missed an assignment, such as this, very poor code:

class B
{
    public int _id { get; set; }
    public StudentRecord _student { get; set; }
    public string _name 
    {
    get { _student._name; }
    set { _student._name = value; }
    }
    
    private B ()
    {
    }      
    
    public string NewToString ()
    {
    return string.Format("{0}-{1}", _id, _name);
    }
    
}

B b = new B();
b._id = 0;
b._name = "Tom";

Which would need to be:

B b = new B();
b._id = 0;
b._student = new StudentRecord();
b._name = "Tom";

Horrid horrid, its bad code, bad coding practice, and using excuses like "This class will be removed later" doesn't really wash with me, because code has a half life you can never predict, you don't know how long your code, or your class, will be around and used and release it in a bad form today, it'll bite you again and again... Release it nicely, with rigourous defensive programming and you'll find yourself not being hassled by it.

Tuesday 18 September 2012

BBC iPlayer Volume


What the fuck is it with the BBC iPlayer not keeping the volume level how you've set it between videos?...

I mean you visit their site and are instantly blasted out your seat by a volume level of 7... So you scurry to turn it down how you like it (or up if you like) then swap show and BOOM its back up to 7 again.

So very very annoying.

Monday 17 September 2012

Sweets for Programming - I


Over the next few weeks, I'm going to be setting up my desk a little better and working more code time at home, in the evenings... Consequently I've decided I need to do something constructive towards my coding productivity at home... I need to pick a sweet to suck on, something to let my mouth idle whilst I mull over complex coding problems.

In America, as I understand it, chewing gum is the vogue, however, gum results in the need to spit, stick or in emergencies swallow its tacky remains.  I prefer a sweet, so that I can suck it to oblivion without worrying.

So, the first sweet I'm picking is the Polo... I love Polo's... The hole, the fact some crumble, whilst others are hard as diamond, they're minty, and great... They also come in a variety of flavours, and the first I've picked is the Spearmint Polo...



I'll let you know how I get along.

DropBox Coffee Script Conversion


I was just reading coverage of DropBox switching to using some CoffeeScript rather than JavaScript in some of their code base, I was insenced enough with confusion over the coverage to post a comment on the thread... Let me give yout he gist...

The folks over at DropBox have changed to this CoffeeScript code in an effort to "simplify" the code... Least this is one of the major reported reasons for their switching out to JavaScript, they also mention removing bugs... and less size/RAM being used.

Analysing this waffer thing argument however and there's a glaring problem... First of all, CoffeeScript "compiles"* down to JavaScript, so there's nothing CoffeeScript does which you can't yourself achieve in JavaScript... If you end up with smaller code from the output of CoffeeScript then you could simply have written your JavaScript better yourself...

Then there's the argument about CoffeeScript being simpler, and easier, to maintain... I argue that CoffeeScript is just someone deciding that they don't like the C style language formatting of JavaScript and opting for a different style, something which looks rather like HASKEL to me... gah... or Occam... Or a myriad of other languages which don't use braces and semi-colons, you can check it out on their site.

Now consider that most programmers worth their salt know a C style language, its more common and arguably more comprehensible, given JavaScript code they could get by... Given CoffeeScript... its rather alien, take for example the JavaScript for a function:

square = function(x)
{
  return x * x;
};

Now, look at the CoffeeScript...

square = (x) -> x * x

I find the second to be too abstract, square equals an x in brackets (which indicate parameters input) pointing at x times x... What the hell does that actually mean?

Where as the first bit... the square equals a function that takes an x... and that function returns x times x... its a bit less alient, a bit less "haahoo we know sucks to you" in the coding community parlance.

The article says it all, my comment, if it gets published says more...

Thursday 13 September 2012

Wii U - Will Fail


Taking a long look at the images released of the new Nintendo Wii U games console, I can only see it being a huge and obvious flop.



Its too bulky, has no cool feel, its performance and specifications are way down on the ladder, there is in fact nothing the device offers that a smart phone already does and smart phones are cool.

This thing may possibly sell in Japan, but for the rest of the world, its going to sink like a stone.

Personally, I wish companies would realise that devices like this don't seem to catch on.  The original GameBoy caught on big time, it filled a void not just a niche.  There was no rival anywhere near the GameBoy, and to some extent its carried that legacy into the newer DS devices range.  But this Wii U is going to go the same way as the Atari Lynx, which it seems to ape in so many ways.



And its to the Lynx I now turn, the Lynx for its part was designed by a creative team, one of its leaders R. J. Mical is a great, and fun, guy; whos fame spreads back to the Amiga 1000 development.  But no-one turned around to that team and really scrutinised the product, sure it had a nobel and dedicated fan base, some people "loved that giant machine". But it was too big and bulky for the main stream.

And here we are 23 years later with Nintendo, the company whom (lets face it) sank the Lynx, stepping themselves over those exact same mistake sink holes full of lava... They'll sink, but they don't seem to see it.

Tuesday 11 September 2012

DayZ Bullet Physics versus Trees


Well, after a week without internet and a very busy day having new carpets fitted, and sorting out a whole bunch of my old junk, I sat down; with the wife - she's so cool; to play some DayZ.

Now, my internet (wireless) signal has been really really screwy, with all the stuff moved about in the house we're getting echo's and shadows in the signal all over the house, so my connection has been so flakey to servers.  I got disconnected from like three servers after a few minutes and then finally got connected to a stable server.

I was on an UK server, that had myself, one other person and then a group of three guys all with the same clan icons "[A2]" I think... Anyway, I hit a military camp and then start to make my way north, rain is bucketing it down and as I enter a small clump of tree's, seemingly in the middle of nowhere, I hear the zip of a shot and then another zip of a shot...

Someone is shooting at me, from an unknown, very distant location... But I can't figure out where from... I can't hear the gun, just the shots hitting the tree's around me... And I can't see any flash of the gun in the dark...

I was tempted to squeeze off a whole mag of M14A1 fire into the blackness, to try to freak them out into moving away, but they don't... I can still hear lots of rounds hitting the tree's, but no direction...

I moved out of cover, and got hit in the legs... luckily I have bandages, morphine and plenty of meat to make up the blood loss and crawl under cover...

And this is where the problems kicked off... I started to lag again, I can hear shots ripping up the foliage above me, and I can't move with a yellow lag out... Suddenly my character glitches onto a small wall and stands up... FUCK FUCK... and I lay down again, but too late, I get hit again, and have to seek refuge to kneel and bandage again.

I think the bandage went on, and then red connection... GAH!!!

But, this was fine, I waited in the bush, hoping it would come back, but it never did so I let the thing fall over and tried to get back on.

It was thrilling, my stupid connection broke the situation, which was intense... But in the end I cowardly left it... And didn't dare go back, or try, with my connection.

Now, this brought me to thinking, what was wrong with the situation?... I could not get a bead on a return shot... I could not hear the shots coming in, just their landing, and I could not hear the source weapon... This was problematic at best...

At worst it was a right royal pain in the back side, I wanted to turn and loose some covering fire in the general direction and then set about running out of there... but which direction?

Now, the shots coming in were hitting the bushes and making a specific sound... so there is a trigger so the game knows that the shots hit the foliage... All it needed was an effect, where leaves and such came out of the tree's in the trail of the bullets, then I'd have known the direction the fire was coming from...

My awesome MSPaint SkillZ

I'm going to post this on the forum, as a suggestion, I think... It'd help those of us (like me) who like to hang out in the bush, rather than spend time in the concrete.

Friday 7 September 2012

Insurance

Insurance companies are free loading con artists, this is an informed and opinionated situation I have come to understand in the most dastardly fashion.  Last year an idiot sped up behind me and lost it, there was no damage to my vehicle and I was not particularly bothered, the woman however was irate, her kids were screaming she was going on and on about being late for a train and she started to take pictures of my car on her smart phone.

So I went to write down her number plate and she screamed at me, tore up the little scrat of paper I had her plate on and she left the scene....

This meant I had a mental woman with my details... And I had nothing....

So, like the good boy I am, I phoned my insurer and let them know... that this was NOT a claim, and I DO NOT WANT TO CLAIM... But this mad woman has my details and is irate... I duly was told by the operator that "no this is not a claim, don't worry, it won't affect your situation"... yadda yadda.

I paid as much mind to this as to fluff under my bed, it was not important, there was no damage, just an irate woman screaming at me... when she was at fault....

Anyway, today I got a renewal quote for my insurance... £917.... WHAT THE FUCK!  I've never ever paid more than £300... ever... And I have (in my youth) actually crashed cars twice.  So to have as far as I'm aware got 14 years no claims and am not paying £917...

I phone the insurer and yes this incident with this irate woman is only down as an actual incident.  I pursued no claim, I never phoned the insurer with the intention of making a claim, I just didn't want her phoning her insurer and claiming I've damaged her car, or calling the police (as she was screaming about) and saying god knows what.

So, I let my insurer know... And you know what they've done?... Added £750 to my quote and cancelled my no claims bonus... I am currently going mental at them... They're going to listen to my original phone call in, and we'll see what they say, but I can't listen to that recording (of my own voice) because "there's a procedure and you have to pay £10"... I'll not mention the insurer in question, but right of now, I've spoken to one nice lad who put me through to a really supercilious sounding lass, a lass who is going to listen to this recording "with my manager".

They're intent on getting my money, and I'm intent on not letting them... This lot have got a lot of work to suck up to me to get my custom back.

Sunday 2 September 2012

Connection or Not...

I'm a little bit surprised that there's suddenly a post from the DayZ team, from Rocket himself, regarding where the mod is going.  Especially since there was nothing said in so long... Its nice to see a post, but the reason for it... I'm not so sure.

The post itself says nothing new... "The patch will be released when its ready"... yadda yadda.  Its not addressed any of the other posts save to blanket them all with the statement "I've been watching and reading and collating your posts".

Yet the only officially released information about the future of the game is about adding dogs... Before they add dogs, they could do with fixing the inventory, the reliability of disappearing guns, the problem of texture popping.... I know most of my problems, with the game, are probably problems with the engine used.  But the guys behind the mod now do work for Bohemia, so they have access to the code all their releases so far have been server side code, they may have also fed fixes or updates into the AO2 beta executable, but they've not officially admitted this...

And, they suddenly post this non-post.  Why?

Well, I actually sent a missive to the team, firstly offering my help, being a veteran forum jockey and modder myself.  And second saying "please post"... I do wonder whether my message met the right ears... Certainly if they simply googled the information I posted they'd know who I am, and that I'm not full of shit when I offer help for the reasons I gave, so I do wonder whether my message garnered a response.