Thursday, 19 October 2017

Gaming, AMD & HP

Over the next few weeks I'm going to be musing about the connections between the humble concept of the PC, where it started for myself, which processors and upgrade options I've taken, which dead-ends I've been down and where that took my gaming experience.

And where I hope to take my gaming experience in the future.

Today of course I'm running a quite nice Intel i7 processor and an EVGA GeForce 1080 GTX graphics card, however, that rig is nearing end of life for me, only the graphics card is a recent edition, and so as a high-performance low budget kind of chap I will be looking at my options, including the latest offerings from both Intel and AMD and the modern differences in nVidia versus AMD graphics offerings.

The secondary thread from this will be a little retro-grade gaming, this is not going to be full on retro - though I am in the mood for some Carrier Command on my Atari ST - we're going to be looking at retro post 2000 stuff.... Watch this space.

So why does this post have "HP" in its title, well... the community out reach team over at HP have sent me a missive, and though they have a zero budget want to share my posts with you guys in the world.

If you came here from a HP/AMD re-tweet, post in the comments below!

Monday, 9 October 2017

The State of Today (Sex Ed)

Lets take a moment to read this:

And realise that this is 2017... 

I'm not saying this to say, "OMG they're not teaching boys about this", but in 1989/1990... When I were at secondary school, we were taught about sex, and periods, and masturbation...

Yes, we were.  I admit there was an awkward moment with Mr Simpson (the Physics teacher - who used to yell - and smell) but he showed us a video and gave us the basics.

Then, in the lower school, there was a personal health conversation with Mrs Salisbury, where she talked to everyone, and explained how periods happen, they're natural, how much menstrual blood (on average etc) ladies deal with and all-sorts of things like that.

I was eleven, I remember it...

So why in 2017 are kids not being taught?... If I had to endure these jaw clenching moments, wondering my eyes around trying to not admit I was hearing this stuff, then damn it kids today should be similarly scarred....

Whilst I'm on the topic, no kids should be able to get access porn online... They need to go get a shot of boobies where I got it, from discarded copied of "The Sun" which have spent a couple of days blowing around the street.

Friday, 6 October 2017

Virgin Media's: Terrible Security

So, in a prior post I made you aware of the situation with myself and Virgin for my services, well... Whilst talking to them they wanted me to give them the "First and Fifth" letter of my security password...

I apparently got this wrong....

"Give me the fourth and the eight"....

I apparently got this wrong....

"Just give me the password...."


This is terrible security, and I said this to them, I asked if they can see my password "yes".  So their system stores my password, in plain text.

I said to the chap "This should be stored as the salted hash of the password, not the actual password, and you should not use it as part of my accessing the account over the phone".  This is the password to access your account, your VirginMedia e-mail, basically everything.

Now, I don't know if this guy was fishing for my whole password bit by bit, or whether he was genuinely looking at the whole thing and just asking for letters, of if he just had some mask of it being shown to him which he asked me the solution to...

But the underlying system clearly stores the plain password, and that's just such a massive security flaw.

Wednesday, 4 October 2017

Virgin Media's : I'm Sick and Tired of You

I've had my broadband with only two companies in twenty years, NTL and then Virgin whom bought NTL.  I've had them at three addresses and never had cause to really complain, sure for a while I had a junction box which would fill with water whenever it rained, so cutting me off, but they sorted that quickly enough.

However, for the last year I've paid for 200mbit speed, super speed, being who I am I immediately started to monitor the speed, and initially I did get around 198mbit download speeds with a constant 12mbit up.

Unfortunately over the last four months that speed has dropped off and off, so much so that my automated server started to report 4mbit.  I tweeted VM about this, of course I received the standard line that this was my equipment.  I called them about it and was told that "over wifi you get much less download speed than you pay for", except I'm using Cat 6 over a gigabit LAN... "Cat what?" the operator asked, as I was simply no longer on their lookup script of replies.

In the end things came to a head when I also noticed that the TV package I was paying for went from a stately total of £50 a month to just over £80.  That's quite a hike, and I looked realistically at what we watched and found it not to be worth it.

The absolute soul cracker was my week away disconnected in Wales, where we had a freeview connected TV, and there was so much choice, right there, free to air.

We were both also sick of the recycled land-line number constantly rining with whoever only knows looking for past holders of the line for debts or catalogues or PPI, so much so I took up a distinct accent whenever answering my own phone to put people off calling.

So, no TV needed, no Telephone we just need basic broadband.

And the persuit began, I knew the name of the exact product I needed, I needed to go from Vivid200 Broadband to Vivid50 - why pay for something you're not getting - and that was it basically, the rest could go, but I thought I'd challenge them...

Now have you ever watched Morgan Spurlocks "Supersize Me!" and it's effect on the fast-food industry?  Well, this same effect is underway within Virgin Media, they upsell, they upscale, they ask if you want to supersize, and they simply can not ever stop doing it, you say "no", you say "stop" you say "less"... And they do not understand.

You're stuck calling a gaggle of people who are not native English speakers, sometimes to lesser or greater effect, and they do not understand you want less.... Three point manefesto in this conversation was simply... "Drop the telephone line, reduce the broadband speed and I'll listen about the TV for ease".

The lines which came back to me beggared belief... "We can not give you a lower rate on your TV without your having the weekend calls"... "Having the calls makes the package cheaper".

The saving through the package £6, the additional cost in the package of a phone line £10.99... So how was I saving anything?  That's right I wasn't, but on their screen the two HAD to go hand in hand, they could not, were unable to, untrained and not savvie enough to realise I had no need for and some concerns with the recycled number of the line we had, but they just could not figure this out.  Extremely poor customer service ensued.

"Your bill is so high because you had the McGregor fight" yes we did have that ordered, yes... "This proves my point, I'm paying for this TV package and still having to pay more to watch the items I want to watch, so where is the incentive for me to pay for the package?"


There was simply no answer to this, the chap then passed me without asking, to a "supervisor", with whom I had to go through this whole rigmorale again.

I'd had 15 minutes of this online, 20 minutes with the first chap, and over a year of issues with the broadband speed and phone line, so I simply snapped... "Cancel it"

"Cancel the TV, Cancel the Telephone, and drop the broadband to VIVID 50 whilst I look for an alternative supplier"

The guy didn't even argue, he just did this, they are so blasé about their customers, we are such sheep, decades of supply are but nothing, they're not interested in you.

Ten minutes later I had started to investigate freeview or freesat to my fancy Sony TV... It has both.

Half an hour later I have over 600 channels on Freesat, with one wire now at the back of my TV, and no additional power usage from their slow TiVo.

The only thing the wife and I are missing is pausing live TV, however, I think the TV will do this with the addition of a USB Harddrive... And I know I have several of them lying around!

In conclusion, fuck you Virgin Media, sick and tired of you.

Friday, 22 September 2017

Thinking C++, rather than C

I'm going to be controvertial... Nothing new about that, but here is comes... Are you ready?

If you are a C++ programmer, and you are using sprintf, you are not writing C++.

There, I've said it, I can't take it back.  Obviously now, I need to qualify this statement, so lets begin.  Obviously, I am over simplifying, and C++ programs can contain calls to sprintf and still be put through the C++ compiler to receive working object code, so I'm not discounting the use of sprintf in C++ programs.

What I'm trying to tell you is that, if you are writing C++, designing C++, and sprintf is your goto method of truncating and outputting various raw data formats together as a string, then you are NOT thinking C++.

You are infact thinking C... Lets hear why this might be a bad idea...

Its about how you are thinking, you are not thinking in the skill-set you think you are.  And though I make a point about sprintf, I am talking about anything within C, if you happen to elect to use a part of the C standard which is not supported in the C++ standard you suddenly have a problem, and potentially derail your project.

And you don't need to worry about this, you don't need to get around it, program around it or turn hoops to achieve that perfect laminar flow in your code and project, instead you simply need to understand where you are crossing the boundary.

Thats easy when we talk about integrating a C++ program with Java or Python, becuase we have to bring in a whole other runtime element or library and we know we are interlinking, however, this cross-bleeding of C into C++ with no formal unification of the two is, in my opinion, more insidious.  Again Bjarne explains why, far more succincly than I can in the above video.

So, up date your way of thinking to lift your thinking into only C++ if you are writing C++, understand when you include CStdLib or CStdIO excetera you are pulling in a different language.

Therefore, even against many other programmers wishes, I will not use sprintf in C++ I will use streams to concatenate across lines of code:

#include <sstream>
#include <string>
const unsigned int c_Age(147);
const std::string c_Name("Xelous");
std::ostringstream l_oss;
l_oss << "Hello World, I am " << c_name << " and I am " << c_Age << " years old";

Rather than sprintf with "%s %i" formatting, because my solution is "more" C++, stronger C++ if you will.

Both sprintf and ostringstream usage achieve the same notional operations here, streams may even be slower, but I remove the over head of worrying about pre-allocating a buffer for the call, I remove the need to worry about deprecated calls or using "sprintf_s" for security, I drop the three decades of evolution in C and jump straight to the current C++ standard in 2017.

P.S. Some of you have asked where I've been for so long without any posts, well I've been in the deep dark depths of Wales, firstly with work, and then ironically I returned with the wife and dogs on a holiday, which was totally disconnected, no mobile, no internet, I read a few books, watched a lot of DVD's and TV, and I recharged my cognitive batteries after eighteen months of strife, but I'm back!

Tuesday, 29 August 2017

Story Time - My First Serious Program

Having a basic knowledge of Commodore Basic v2.0 I took to my A-Levels in 1994 and started to learn Pascal, both "Turbo Pascal" on DOS and "Personal Pascal" on my Atari ST.

One of the first things I did, as most kids do is start to write a game, it was a 2D grid style war-game, 28x28 tiles to a map and maps stitched together, it was very roughly based on a table top game I had which itself was a dice & splice of the Guadalcanal Campaign of World War 2... Anyway, I had jungle, and grass, Desert and beaches, water and the tanks, and troop counters moved around, you could air-drop paratroopers into spots when you had earned enough points, and I last worked on it in around 1995 when I started to add Sound Blaster driven 16bit effects into it.

But, I also needed tools, I was working on DOS, with no Windows - I didn't get Windows 3.1 until later that year - and at college the compiler only ran in DOS, to stop the compiler and loads Windows, then execute a GUI tool just to exit again and load the IDE was not a workable solution, therefore I started to write a bunch of EGA based tools directly in DOS, drawing graphics in DOS.

The first tool was a simple string comparer, almost a version of "Diff" which I used for comparing old and new files.  The second tool was a back-up tool, to indicate the copying of files into a floppy, so I could squirrel them away.

Finally, I needed a serious tool, this was a graphics tool... Almost a version of Paint for DOS.  To help design maps and other information in my game.  It worked by letting me place squares and circles, lines and even text into set places on the screen... It looked just like this...

Unlike anyone else in the class of A-Level students (as far as I know) I was the only one who knew about Interupts and could therefore use the mouse in DOS, so this blew a few people away.

This could save my image too, and I built up a very basic form of "Vector" graphics, without actually knowing what vector graphics were.

Later on, I came to add scale and delete to these items too, and this is where my innocence as a new programmer came along, I first started doing delete by using "GetPixel" to return the colour of the pixel below the mouse cursor, however, this failed terribly the moment I run it up and realised if I clicked on either the red circle or the red square both would vanish and I only had 16 colours in my pallette and really got disheartened.

So, I came up with a scheme to get more colours and workout which item I had clicked on... I went to grey scale, I converted each shape in the list of shapes to a grey scale of RGB (0x01, 0x01, 0x01) to RGB (0xFE, 0xFE, 0xFE)... This suddenly gave me 253 possible shapes in my list (as I used black and white as control colours), but 16 versus 253 I thought I was making HUGE strides.

I could then look up the pixel at the X, Y of the mouse to delete the actual shape below the mouse when delete mode was set... Nifty... So my mind thought, it was certainly a programming exercise, and very laborious on the 25Mhz 486 CPU's the college had.  Only much later did I think about accessing the back-buffer directly, locking the bits and stepping over the image in scan lines at vastly higher speed, anyway...

My next challenge for this program was to stop shapes overlapping, I immediately went to my grey scale mode, and started to so this... as the song goes... with "White Lines".... 

As the line of white moved across line by line, pixel by pixel, really really slowly, it checked if it found a grey - rather than black - making the pixel flip from RGB (0x00, 0x00, 0x00) to (0xFF, 0xFF, 0xFF), if the pixel ALSO was the RGB of the Grey shape I was adding, then this was left black, like so...

And I knew the shape was "free floating", with no overlaps... However, if there was an overlay, I added the RGB differently... So I could see the overlay... like so...

I was not only doing the processing live on screen, but it acted as a debugger for me as I went, without needing to spool up the Turbo Pascal Debugger on my measly 543K of free RAM.

This was a serious amount of work for me, when I learned a lot more about programming I came back to this briefly, but it never warmed my cockles more than when I wrote this program for the first time, I learned so much, I learned patience, to think a head, to plan, to process flow, to research the topic and ultimately to get things done first - in a prototype - and then revisit them.

I also ultimately used this same code later, at university in C++... Making this the first time I had prototyped a working application in one language (Pascal) and converted it to another (C++) and could say it was properly prototyped.  The latter use as as s tool to layout gardens in a sort of designer, I remember far less about the C++ version than the Pascal version.  But it's shadow lasts a long time, and remains over me today, I recall so much more about this one application than most of the others I wrote at the time, because it was something I engaged with.

I can only express to any budding programmer today, no matter that language you use, to just dive in there... 

Friday, 25 August 2017

The Great Bread Mystery

I came to make my sandwiches the other morning, and pulling open the brand new loaf immediately saw this odd shape on all the slices, which collapsed to an air pocket towards the bottom of the stack.

It's a hard, dough smelling thing, quite unpalatable.

I of course asked my colleague the former GBBO contestant Jordon Cox quite what he thought it might be... "Ewwwww" was his reply.

The manufacturer of this particular loaf is yet to reply to my query, as it wasn't a cheap loaf I'll tell you that much.

Thursday, 24 August 2017

Hard Drive Heat Problem

Most of us are well aware of how much heat electronic equipment puts out, what can be less intuitive and harder to balance is the problem of heat from hard drives.

Good organised machine operation, with clearly defined device usages, easy control of units across machines, sites or different customers is the key, therefore enter stage left a nice fat label to hold all the details of the unit.

Except, this label acts as a heat blocker, reducing the surface area of the metallic or foil labelled drive as delivered, reducing the area across which the heat from the unit can dissipate, and even causing uneven heating, or heat wearing over time.

The net result... For my project, a high mechanical drive mortality rate, which I simply could not explain, nor model or explain in the man lab.

Only a trip to see how these machines were being employed sufficed to show the problem, label after label applied and reapplied, a drive on within a machine was untouchable it got so hot.  My solution, put a number on the drive in marker pen and link that number to a database entry with all the drive information.

This solved the heat death problem.

But it also opened up the scope of the information being transmitted, with access to any smart phone the customer could then look up the information, so could their designated engineer, they need never bother me - which is again key to efficient business practice.

Like-wise those not wanting the quite useful information on the harddrive to be public, simply have their information about the drive secured away behind a password on the site, or even more simply not on the site.

Options and solutions, that's how I see this problem benefiting projects going forward... If only we'd not been putting label after label on for year after year.

Saturday, 19 August 2017

That Moment...

You know that moment when you see this...

And the mage rolls need....

Yeah, that's the kind of day I've had.

More World of Warcraft topics to follow...

Thursday, 10 August 2017

People: Email & Names

When you interact with someone, say face to face, you get to gauge who they are, what they're thinking, the subtle and many clues from body language, posture, intonation and even just where they're looking tell you an awful lot about how that person works, how they think, whether you agree with them.

However, when you're communicating digitally, via e-mail or text, you loose this personal grip.

One has to therefore rely on the face value of the information presented, is it spelt correctly, is the grammar correct, have they thought out the reply and addressed all your requirements from anything you sent them?

In my case I am often asked things like... "What do you do to better yourself?"... "Or have you done anything of note recently"... And I'm asked by people who have read my blog, or CV, or just know me... And I often say "Have you read my book?... Have you read my Blog?"

This kind of interaction puts me on a huge downer, why should I bother with this person if they've not performed what I consider the basics of due diligence?

Then there's my huge pet peeve in E-mail... I send a mail... "Dear whoever, bla bla... Xel"... They reply... "Dear Zel"...

No, not "Zel"... "Xel"... spelling, and it's not just spelling, it's that you've been given the answer right in front of you, if you can't have been bothered to take the last thing you read, and put it into the first thing you write, you're being lazy or worst still you're being purposefully obstructive and annoying, because this grates on me so much.

I once worked with a lady called "Grace", she hated being called anything else, "Gracie", "Gracy", "G-dog"... All really, really annoyed her... and people did this day in, and day out, her final response was to stop communicating with these people with their own names... Even our co-boss, who was a "Mr Khan", he became "Mr Purple-Whipple-Snapple"...

When he queried this, she said "if you wish to call me G-Dog, I will call you anything I like also".

It was the perfect most polite and poignant reply on this matter ever seen, but it took a silly outrageous example to make this clear, if you can't call "Robert" a "Robert" on the next page, or a "Susan" a "Susan", or even a "Xel" a "Xel" don't reply.

Wednesday, 9 August 2017

Development: Silly Things Said in Software

"Rather than get away from the concept of the password required completely, the password is hard coded as 'password'"...

I literally just heard this statement, from a senior software engineer ten feet from my desk to another engineer as they consulted with one another about the system they are working on.  And I simply can't let it go... So here I am to have a moan....

The problem with this kind of thinking really annoys me, they could make passwords optional with configuration, meaning the option is present and supported.  They could remove the passwords altogether, as 'password' as a password is not a password at all, it only leverages an attacker to want to rip the soul from your data and scatter it to the four winds.

But more than that, remove the password if it's useless code, don't complicate the system, don't exacerbate the effort to maintain the code.

There are so many faults in the way this engineer is thinking I'm quite pleased I don't work directly with them; and luckily - as they're departing these fair shores in a fortnight - I never will.

Aaaannnnnddd... Relax...

Seriously though folks, don't over complicate things, if you use good source control you can resurrect sections of code from the previous revisions easily, so get drastic, get smarter in the process, chop and cut your code to bits.

This video from the 2 1/2 minute - ish - mark really shows you the process from someone else's eye... and I agree with him, when he talks about thinking about what's beyond scope, however, this also needs to be considered from the point of view of maintaining the code once released.

Monday, 7 August 2017

Life Tip...

Top tip... If you run a business... And print people invoices... Learn to count... Tip ends.

This story is to be continued....

Wednesday, 2 August 2017

Development: Design, Prototype then Code

When I were a lad, I were taught to use flow chart stencils....

I was shown how to write data dictionaries, to thought-cloud through the possible data members for these dictionaries, to define the mutable and non-mutable points and abstract away the common elements between these definitions in order to design the code to be written.

All pretty much on paper, before you sat before the computer.

The reason being?  Paper was cheaper than electricity, and it took a long time to compile and recompile, and then even longer to debug, a program.  Bugs got hidden and only appeared when testing took place.

And if a bug ended up in test, which could obviously have been caught on paper, long before it reached the coding phase, then you got egg on your face.  In a nice way, you all knew you had to do more than cut code.

Unfortunately Moores law exists, a blessing, and a curse.  As I feel it's made the quality of software design fall, as people can afford to code and compile and try before thinking.

No-one I work with, certainly no-one immediately around me, designs anything on paper, or performs thought exercises on the task before diving at the keyboard.  Event when they have dived at a keyboard they're not prototyping, they're immediately producing code for release use, and it's starting to show.

As such, I've instigated a new rule, "if you have to prototype, it must be in a different language to the release code", the language I've stipulated is a python for system scripts or data processing tasks, and C# to replace any windows C++ being produced.  For C# I'm still thinking, but Java might be the best option...

This realisation came to be from the back of my mind, and it came from experience, however it seems other authors have had thoughts along these lines:

"One trick to ensuring your prototype code isn't obliged to become real code is to write it in a language different from the one your game uses.  That way, you have to rewrite it before it can end up in your actual game" - Robert Nystrom.

Tuesday, 25 July 2017

C++ Multiboxing : World of Warcraft

I'm a huge fan of the early World of Warcraft games, I make no secret of this, and spent far far too long playing the game when it came out.  I enjoyed the game into Burning Crusade and enjoyed PVP during Wrath of the Litchking, but I think somewhere along the way there Blizzard lost their mind.

And way back in 2010, on the then in vogue talk show "Shut Up We're Talking", I predicted where I thought things would go, and that looks pretty much to be where the game has gone, it's been dumbed down, and the MMORPG inflation on damage and stats has become insipid throughout.

As such, I crave a Vanilla experience, and wish Blizzard would allow the free usage of the Vanilla assets (mainly extracted client data) for all the server emulations out there - Nostalrius and Felmyst come to mind.

Until that happens however, I'm stuck exploring the old game myself, alone... Yes, I still have the original client DVD's I purchased in my battlechest and armed with CMangos, I have been building up my old multiboxer from 2014.

The result tonight is my first Boss kill, Scarlet Monestary Graveyard run... Not perfect, the summoning by "Haunting Phantasms" really screwed me up, my mages won't decurse on command, and the priest keeps pulling aggro as her fade is slow... but other than that, we got somewhere, and I really enjoyed myself...

Click to enlarge.

You can see on the detail screen the top left client is the one I'm playing the warrior, I am tanking... Bottom right is the priest, the only healer, and the group is a warlock (top right) and two mages in the smaller windows center bottom.

The command prompt window is the multiboxer, it simply takes key presses of one key, say "numpad 5" and delivers them to the other four clients running as windows key down messages but of another key code.  So, 5... Hence making the fifth item in the action bar cast.

Shift and 1, will select action bar 1... etc etc... I have a myriad of little command helpers.

However, the boxers are totally dumb, they are only being controlled by myself, at my keyboard, alone.  No hacks, no injection, no memory scanning, just me and my eyeball mark 1.

My ultimate aim is to run Scholo - I love Scholomance!

Tuesday, 18 July 2017

Speak More Slowly Please

I'm English, this means I speak English, or at least a dialect of it... This mere fact has furnished me with the ability to communicate to a myriad of other people, of different nationalities and inclinations.

However, it completely alienates me from the French.

Well, a certain sub-set of French speakers, whom simply are rude... Now, I'm sorry, but these people exist, and good on them, they want to protect their beloved French language from the likes of me, coming along speaking it with a terrible rich British Midlands accent.

I accept that.

I'm not trying to compose poetry in French, I'm just trying to communicate with someone, so when I say:

"parlez plus lentement sil vous plais, je ne pas parlez Francais bon"

I think I'm asking them to speak more slowly please, as I don't speak French very well.  I don't expect them to stop the conversation completely, roll their eyes and then turn their back on me.  That's rude.

And this wasn't an isolated case, since the mid-90's it's happened a few times.  And every single time it annoys me more.

When a French person speaks to me with strongly accented and semantically incorrect English, I of course listen to them, I'll even take a stab at working out what they were intimating, I'll smile and maintain eye contact, reassure them they are okay to just try... Very much a "we'll get there together" feel to the conversation.

Some French speakers however... Just Rude.

There, I've said it, I'll leave this here....

This post also may give away why there's been a small break in posts for the last half month... No I've not been anywhere, but I have been extremely busy.

Saturday, 1 July 2017

4000 Monthly Viewers

Back in May I came to these pages to thank my Russian viewers and I mentioned I had passed the 1000 viewers a month mark...

Well, here we are on the first of July, with the numbers in for June... 4143 viewers.... What the?

Where are all you guys coming from?  The google stats don't tell me :)

Monday, 26 June 2017

Computing Education 2017

Here in the UK there have been several waves of trying to educate new generations as to the art of compute science, this started when I was a boy with the BBC Computer Literacy project and concluded soon after with a drought of interest from non-technical educators and politicians a like through until fairly recently.

The BBC reports that there has been a low amount of uptake of new Computer Science GCSE studies.

And I can believe this, however the neither the BBC nor government seems to even point as to why this is, they talk about pupil disengagement or lack of interest.

I however contend that the government and educators and indeed the BBC completely fail to spot the elephant in the room, kids study not for jobs or skills, however they do study what is emphasised, IT has always been an "also ran" topic, it's not Maths, nor English nor seemingly as important in appearance as any other topic out there.

In my day this was the case because few understood computing, today however it seems IT is still an unimportant subject, today it's seen as unimportant because of it's ubiquitity.  Kids see easy to use computers, they walk around with them on their wrists, on their pockets, they are the always online generation.  If they need now know how to do more than turn the wifi on why should they care?

Likewise the educators see using a modern computer as easy, so why should it be a subject of study really?

And finally, the basest of problems, is the employers, if employers are willing to employ a programmer who studied horticulture, why should one study computing?  If the employer will take on an IT support operative who has no qualifications but whom is handy with a screw driver and knows how to plug the right parts of a PC together, then why should they bother to get formal qualifications?

Ultimately, for computing to be taken seriously, you need a passion for it, you also however need a reason to study it, and until that reason exists in the form of accessible all tier jobs that actually require a formal computing qualification there is little hope in pushing back up the chain to educators or government that computing is important and needs to be studied.

Friday, 23 June 2017

Development : My Top Three Testing Tips

I've said before, and I'll say again, I'm not a fan of Test Driven Development, tests and test frameworks have their place, but they should not; in my opinion; be the driving force behind a projects development stream - even if it does give managers above the dev team a warm fuzzy sense of security, or if it allows blame to be appropriated later, you're a team, work as a team and use tests on a per-developer basis as a tool not as a business rule.

*cough* I do go off topic at the start of posts don't I... *heerrhum*, right... Top Three Automated Testing Tips... From my years of experience...

1. Do not test items which are tested by masses of other developers... I'm talking about when you're using a frame work of library, ensure you are using it correctly certainly, do this at training or with your coding standard, but then do not labour the point by re-testing... Lets take a good example of this, the C++ Standard Library.

The Standard Library contains many collection classes, these classes have iterators within, lets look at a vector:

#include <vector>

std::vector<int> g_SomeNumbers { 1, 3, 5, 7, 9 };

We could iterate over the collection and output it thus:

int g_Sum(0);
for (int i (0); i < g_SomeNumbers.size(); ++i)
    g_Sum += g_SomeNumbers[i];

However, this is not leveraging the STL properly, you are introducing the need to test the start poing "int i(0);" the end condition "i < g_SomeNumbers.size();" and the iterator "++i", three tests, slowing your system down and complicating your code base.

int g_Sum(0);
for (int i (0); i < g_SomeNumbers.size(); ++i)
    g_Sum += g_SomeNumbers[i];

Using the iterator, we leverage all the testing of the STL, we remove the need to range test the count variable, we remove the need to test the condition and leave only the step as a test to carry out...

int g_Sum(0);
for (auto i(g_SomeNumbers.cbegin()); i != g_SomeNumbers.cend(); ++i)
    g_Sum += (*i);

Our code looks a little more alien to oldé timé programmers however, it's far more robust and requires less tests simply because we can trust the STL implementation, if we could not thousands, hundreds of thousand of developers with billions of other lines of code would have noticed the issue, our trivial tests show nothing of gain, so long as we've written the code to a standard which uses the interface correctly...

int g_Sum(0);
for (auto i(g_SomeNumbers.cbegin()); i != g_SomeNumbers.cend(); ++i)
    g_Sum += (*i);

2. Do now allow values which have been tested to change unexpectedly... I'm of course talking about "const", which I have covered before on these pages, but constness in programming is key.  The C family of languages allow constness at the variable level, you may notice in the previous point I used a const iterator (with cbegin and cend) as I do not want the loop to change the values within the vector... Constness removes, utterly, the need to perform any tests upon the integrity of your data.

If it's constant, if the access to it is constant, you do not need to test for mutations of the values.

Your coding standard, automated scripts upon source control submissions, and peer review are your key allies in maintaining this discipline, however it's roots stretch back into the system design and anlysis stages of the project, to before code was cut, when you were discussing and layout out the development pathway, you should identify your data consider it constant, lock it down, and only write code allowing access to mutable references of it as and when necessary.

Removing the need to retest mutable calls, removing the need to log when a mutable value is called because you trust the code is key.

In languages, such as python, which do not directly offer constness, you have to build it in, one convention is to declare members of classes with underscores to intimate they are members, I still prefer my "m_" for members and "c_" for constants, therefore my post-repository submit hooks run scripts which check for assigning to, or manipulation of "c_" variables.  Very useful, but identified by the coding standard, enforced by peep review, and therefore removed from the burden of the test phase.

3. Remove foreign code from your base... I'm referring to code in another language, any scripting, any SQL for instance, anything which is not the pure language you are working within should be removed from the inline code.

This may mean a stored procedure to store the physical SQL, rather than inline queries throughout your code, it maybe the shifting of javascript functions to a separate file and their being imported within the header of an HTML page.

But it also includes the words we ourselves use, be that error messages, internationalisation, everything except code comments which is in whatever language you use (English, French etc etc) should be abstracted away and out of your code.

Your ways of working, coding standards, analysis and design have to take this into account, constness plays it's part as well, as does mutability, where ever you move this language to, and whatever form it takes test it a head of time, and then redact that test from your system level tests, trust you did it right based on the abstraction you've performed.  Then avoid burdening your system throughout the remaining development cycle.

One could expand this to say "any in-house libraries you utilise, trust their testing" just as I stated with the STL in my first point, however, I am not talking about code, I am talking about things which are not code, which are uniquely humanly interpretable.

The advantage of removing them and pre-testing the access to them is that you retain one location at which you have an interlink, one place at which a value appears, one place where they all reside and so you leverage easily converting your programs language, you leverage easily correcting a spelling mistake, and all without needing to change your system code; perhaps without needing to even re-release or re-build the software itself (depending on how you link to the lingual elements)

Ultimately reducing the amount of testing required.

Wednesday, 21 June 2017

Development : Coding Style Clash

I've spoken on these pages before, and even shown, that I generally code to a standard, one of the rules I have it NOT to use Hungarian notation, but to use a notation telling me the scope of a variable, and then give it a meaningful name.

Now, over the last few weeks I've been involved in a new piece of coding with a group of like-minded individuals.  And what getter way to explain this oxymoron than through our coding standards.

Now, I like to use "m_" for member, lots of people can accept this, I like "p_" for parameters, a lesser few reject this than you'd think and some people even quite like this as they suddenly get to reuse their useful meaningful names, and in languages like Python they suddenly get to distinguish between locals, globals and parameters really easily... But then the controvertial one, the one which causes me most angst.

Locals being represented with "l_"... You might say the lower case "L" is asking for trouble, and I would agree, but I'm sticking with "l_" locals, and so did lots of other folks, however... I said we're a group of like-minded individuals... So not a group at all.

And so locals caused a bit of a flare up, because another chap had simultaneously, and without any prompting of mine, also come to the conclusion to use this same naming convension, however with one difference... He didn't call locals locals, he called locals instances, and so he used "i_".

Yes, that was it, the whole difference... "l_" to "i_"....

I could live with this, and when coming to look at his code I could read it perfectly well, and I was more than able to leave it alone, he however, could not, and indeed would not, leave mine alone.  He went so far as to write a script which line by line, looked for "l_" and replaced it with "i_" whenever he pulled from the remote branches.

He then proceeded to commit this massive change, the result... His one liner alteration was lost in a swamp of about 35,000 changes in his check-in.  Making his contributions near impossible to track.  I asked him to keep this just to his branches, and to stick to the "l_" for the master or pushes he tagged for merging, but he simply would not listen, he changed every "l_" to "i_".

Trivial things like:

std::mutex m_TheLock;

void Somefunction()
    std::lock_guard<std::mutex> l_LocalLock(m_TheLock);


std::mutex m_TheLock;

void Somefunction()
    std::lock_guard<std::mutex> i_LocalLock(m_TheLock);

And the change logs got longer and longer, the tracking of bugs became harder and harder, until I decided to pull my support of the project, and this is important, not because it looked like a hissy-fit on my part.

But it demonstrated to me something fundamental about the project, I happily bent to others, I let them name and title things, I didn't fix their code, only stuck to my own, I published my coding standard and people started to adopt it within the group, but I never forced it upon them.  Yet this one chap wanted to import and force his will through this tiny insignificant thing.

So, always, no matter your personal feeling, stay flexible, don't be that guy who insists on something for zero gain (or in this case much loss).

[Foot note: If your project/group/team has a manager, a leader, and is not a collective as the above, please disregard this, have a coding standard, make it clear, efficient and update it regularly, but have ONE person enforce it, don't let two tribes go to war over "i_"].

Monday, 19 June 2017

Bash : Power of Pipes

Subtitle: "Get IP Address Easily"

When I say easily, I mean not so easily, but with the proper tools... Let me explain, it's been one of those days... I've a remote server running some flavour of Linux, and no-one knows it's remote IP Address, they all SSH into the box run "ifconfig" and note down the value, they then plug this into a config (or worse still were baking it directly into some code) and running their services....

The trouble of course being, years later, they're no-longer the programmers nor maintainers of this machine, I am...

And to be frank whenever the IP address changes I don't want to recompile their java code, nor use vi to edit the various configuration files, I want a script to at least update the settings automatically.

I therefore changed their code to load the IP address, not hard code it, and used some other scripts to put the IP address into the config file at boot...

The first line of that script is what I'm going to document here... so it starts:

#! /bin/bash
ifconfig | grep inet | tr ' ' '\n' | sed -u '/^$/d' | head -2 | tail -1 > ipaddress.txt

This script gives me a single line of text with the IP Address in it, for the one and only adapter in the machine, if you have multiple adapters you'd have to play about with the grep inet to select the row you want with a head & tail call before moving into the  final location, or whatever...

I wrote this up however, and immediately started to use the IP address.

The net result was a request to explain all this functionality to a colleague... Here's what I came up with.

ifconfig gets us the adapter information...
grep strips off lines we don't want only giving lines for the inet adapter
translate turns spaces into new lines
the sed call removes the blank lines, giving just the IP address and some guff
the first adapter IP address is therefore always the second line of this output
we select the first two lines with head
then select only the latter of these two with tail
and write this to a file

Her reply... "What are the Lines?"....

"What lines?"...

"These | things"....

"They're pipes, I'm piping the information from one program to the next..."


"Do you know what pipes do in Unix and Linux?"


I sent her to this video...