Friday, 5 August 2022

I hate FizzBuzz and Will Analyse anyone who uses it

One FizzBuzz Interview so far.... News flash... The moment I am asked to write FizzBuzz during a technical test I intentionally stop and ask the questions from there on out.  I've done this a couple of times.  And you know what I learned... I learned a whole lot more about the interviewer and their processed than they found out about me.

Let me take you back to a technical interview I had about five years ago.

I drive up to the building, it is way out in the sticks; just about still in my home county, but so obscure it's in a part I have never ever been in.

I pull up and the building is like a box of black glass, no character, no soul, just a box.  The non-native tree species planted around it to discourage birds actually using the tree's and the austere grass puts me off.

Things don't get any better, for I walk through the door and there's no secretary, no desk, nothing... The lights aren't even on; this doesn't bode well.  I look around for a buzzer, a phone even a limp notice of what to do.  When a door opens and a man approaches offering me a hand to shake.  He leads me to a similarly deserted corridor with a chair in it and I'm left to my devices once again.

I read some inane notice about some award some member of the staff had received (this is important later in the interview) and I read the fire evacuation notice.  It's quiet, quiet and silent.  There's one door nearby with a few people within and another which is a closed office piled with stacks of desks..... Empty corridors - which would be dev spaces, massive rooms with a few people in them, no secretary and piles of desks?  What have I walked into?

About ten minutes later I'm ushered into this room, I've brought my CV a few piece of detail about me and some references to my technical projects at home; as well as references to some of the discussions I have on these very pages and my github.  You know actual technical things, which you can see me achieving.

I can't talk about my current work with them... Heck I can't talk to you guys about my work now.  But I do it, and I pay a mortgage; that's all the proof I can proffer.

Anyway, I seat myself and a lady explains their technical lead will come and perform the technical test, he enters a moment later with a massively overpowered gaming laptop.  I hate gaming laptops.

I much prefer a simple sleak laptop, a decent screen, nice keyboard and plenty of battery life; and I do my work on a remote machine via SSH or whatever machinations you wish.  I do not generally work on my laptop, it's a portal onto other more powerful machines which are tethered, and this way I can go take my laptop with me anywhere and get amazing performance from it, as I'm only interested in a bit of internet, RAM and then remoting into other services.

Anyway, he plonks this behemoth down and proceeds to tell me about test driven development... TDD.

I HATE TDD.

Now, I know test have a place, heck I really like doctest, including tests into code you've written, to ensure it is within specification is perfect, and validates your progress.

My hatred comes from writing tests up front, I find this backwards logic, and I don't think you could ever persuade me otherwise.  Define the scope of your input, validate it in your code (I often assert up front when data is unexpected or malformed, or at the very least bail early) and then you run your code, and then TEST the result.  I do not believe you should write a test and then further write the code to fulfill that test.

You will miss something, you will be thinking about the test as the solution, rather than the solution itself.

If anything writing the test and then producing the code to meet that test may very well be called TDD today, but when I was a lad it was called Prototyping.  And though I'm sure we can all agree prototyping is best done in a language different to your final product, it is not really prototyping when you are not producing the product, you're producing a test.

I find it wasteful of time, and often ignores enough scope, for instance I've seen a fair few hundred thousand up front tests written and then the code to meet them in my time, never have I seen a validation of the input data, the input has generally been hard set into the test.  That's not as wise a test-scope of ensuring the result after the fact.

(This does not mean test suits after the fact are the best, I just think they're the best for my style; not least as they are opt-in, for those times you are in a swing, and easy to add later).

So, TDD... Why is he telling me about TDD?

He does, he explains they have a method and that method is structured, he does not offer me any test framework specifically, instead he opens notepad and asked me to write FizzBuzz.

And the interview stops there; I don't think the guy realised it, but I stopped being interviewed at that point, I was not going to accept their job even if offered, but I wanted to see where this lad (and he was young) was going with his thinking.

This half empty hulking building and they're trying to hire engineers, and he is going on about TDD but FizzBuzz?

So I play total dumb, I simply start to write "int main"... And he surprises me.

"No No, start with the test".

Ohkakkkakay....

I have NO idea what test suites he has installed, I don't use G-Test or Boost-Test, I use doctest.  So I write a SCENARIO; he blinks and just takes the laptop off of me and starts to open some other window... I didn't know he would allow me to open some other window, this isn't my machine, I don't know what he has installed.

This sort of sums up TDD to me, the tools aren't easily defined.

Anyway, twenty minutes later and I just about have it Buzzing on 5's and I'm not very interested, I've come to a conclusion.

He isn't impressed; rightly so, but he has no idea he's just been investigated by an older and more cynical mind than his.

He leaves and no less than three people come into continue the conversation, and boy do they, they talk to me for a solid 120 minutes; I timed it... I was so bored.  But I engaged a little when they talked about their award winning technology.

I recall the poster for the lady who had won this award and mention her, by name.

"What, how do you, who has been talking to you?"

This is very strange, "no" I assure them "no-one, I saw the poster on the notice board".  One of the two girls flanking the chap in the middle here makes a note.

They talk to me about the company a bit more, they talk about their re-shuffling engineering and wanting to press their position forward to a virtual machine the customer hosts on hardware; previously they had been providing a dedicated box.

I'm terminally not interested in this boring black blocky building which now perfectly reflects the boring blocky people inside.

And I give up, I lean forward, elbows on the table, and I gather the copies of my CV from the hands of the three people and I say:

"Look, I've spoken with your technical lead, and I'm scared to my core of your processes, I don't like what I've heard, it seems you're struggling to recruit and there are reasons for this you will have to identify yourselves; I don't think I can help you"

They are scowling a little here, I'm sure they're far more used to candidates who want the job.

"Indeed, I think somewhere you have a beige room with ranks of screens and engineers in stuff suits not talking with a great board or wiki with all the failing builds traffic lit from your little test driven development board...."

At this point the lady on the left looks at the guy in the middle, who has a little switch to his eye.

"And such a stifling, control freak, desperate development environment is not one I wish to be part of"

They thank me, and I thank them sincerely.  And I leave.

As I come out of the building the sun has come around, the black glass face of the building is now not so black, instead I can see inside, there are three long benches of PC's all facing a pair of chaps at the front sporting bluetooth ear phones in one ear.  Above their heads is a large TV screen with a list of running continuous integration tasks and each has a traffic light.  As I watch one goes red, one of the two larger men touches the headset at his ear and an engineer on one of the benches glances up and starts to scrabble about on their machine.

It is a sweat shop.  I was not only right, but so happy I'm driving off.

I felt like going and knocking on the glass and cooing at them "Come, follow me, be free, be free".

But instead I just drove home.




Prior me: Just coming into edit this before it goes live on Friday, guess what I'm watching... 


And I disagree with the approach of analysing FizzBuzz; analyse the interviewer.

Friday, 29 July 2022

Embarrassing #3: Source Control

We spin far forwards not to around 2016; and the development manager wonders over to me and asks my opinion on source control software.  GIT.  Is my reply, just Git no other shenanigans.  But he wants a report.

I duly go take a look... I've suffered CVS, SVN and a myriad of other source control solutions, Git has always worked solidly for me, in over a decade I've had one fault with it - and was able to recover from that problem easily.  That is fabulous uptime for me and nearly zero support because anyone using my repo's could just learn (or google) a bit of git.

SVN was the other main source control solution I advocated, it's issues are many, but it worked for the problems I was dealing with (indeed on my youtube you will find subversion tutorials from back in the day).

This manager however wanted more than opinion, I wrote him a pro's and con's, I went to the public for their opinion and looked at a few closed source alternatives; like perforce.

Cost was a MAJOR issue for this company, the cost to install Git was zero.  The cost to install Perforce was nearly £27,800.  It was a clear win win for Git and vouched for it again, arguing it'd be better to pay for a whole other junior developer; or paying the ones we have now that little bit more each than going for Perforce.

(And I'm being harsh here, but I don't like perforce, I see the "game industry" using it as a default goto, but I do not see why, it has bitten me more than a dozen times in four years of heavy use - I compare that to once in over ten for git and it's just a no brainer even before the costs; and git will do the huge repo's and do them better than perforce can - which was the default argument before that git didn't do huge repo's or source tree's... erm, hello, Linux is completely on it and huge.... Microsoft have moved to it, so windows, edge and so much of their stack is all hosted on git repo's - stop arguing for perforce, it's embarrassing, seriously).

So this manager took away my report.

They bought Perforce, six months later, he's getting the nagware for license renewal, per seat.  £12,000.  This just beggars belief.

The manager was wrong, the money was spent, the company still disappeared with a whimper, it was a waste.  He should have been embarrassed by that; I doubt he was.

But the management should have been far more embarrassed letting him operate the way he did.

Friday, 22 July 2022

Embarrassing #2: Threads

The next story of embarrassment is one of my own, after my experience in my degree I literally specialized in the Borland implementation of the C++ compiler, and the Turbo Pascal one before it.  Java was new on the scene, and so my first job was to go port old Pascal programs into C++ all using C++ Builder.

At a trade show I was poached by the head of finance of another first, not a rival, a completely other market sector, but she wanted me to work for her... I therefore did.  And this meant a physical house move in the process.

This woman being the head of finance would be important later down the line, as she had an idea where I would sit in the business and I duly showed up.  In actual fact I showed up so early I entered the property without permission through an open door and caused a bit of a stir because I was all alone; and could have been anyone not just a new employee.

So I began work and the data processing they wanted was incredibly slow.  This was the era of the Pentium III being king, and my machine was a 400Hmz machine, not a slouch for that year.  But still it was very slow, you had to take a feed of data from IO and process it live; not all of it could fit into memory; so you often had the process spinning waiting on the disks.

I delivered the first iteration just like this, a single inline 1:1 just get her done.  It was horrifically slow.  My embarrassment?  I didn't even understand why it was slow, the manager looked at me; sternly, this kid he didn't really want, and pointed me to "BeginThread".

There wasn't any internet access, no stack overflow, you had to learn by the seat of your pants.  So I cracked open the windows headers for threading in Windows 95 (I forget the SDK version) and start to look at starting a thread.  I had to read about MFC too and a bunch of other stuff in this Microsoft compiler which was not in Borland's; or was different.

I don't think the engineering manager understood I could do all this in Borland, just not in Microsoft.

With these old eyes I look back at this episode and I laugh when kids today complain about std::thread, lambda's, Futures, Async dispatch.  You guys do not know how lucky you are!

And I was embarrassed by not knowing this stuff, worse still was going home to my machine at home, and not being able to follow any of this up, I could read about things, make notes, but not implement any of it; for my machine at home I only had the Borland stuff (and a pretty penny I paid - unbeknownst to me they would soon give away C++ Builder on PC Magazine cover discs).

Ultimately today, to me, this is a lesson in the history of compiler differences between vendors, but at the time I was mortified.  I promised myself I'd never fall behind or out of step like that again, and I've so far achieved it.  Though I had to admit to being off the boil with C++20 right now.

Friday, 15 July 2022

Embarrassing #1: Plagarism in Academia

It has been a while since a regular post series, so inspired by TheRegister's on call - and re-reading my own older "Rackmount Mistakes" stories I thought I'd share three true stories of embarrassment from my career; we're going to start with academic and go into my employment, we'll talk about times I was embarrassed, embarrassed myself or someone else embarrassed themselves.

And why am I doing this?  Well, in the move from immaturity to now I believe a true part of blossoming as a software engineer has been to embrace ones own failures and not repeat them, and identify them in others and work around them, encouraging them to improve.


Unfortunately my first story can't say it improved me or the person whom embarrassed me... We spool the clock back to 1997.  I was in the middle of my degree and I received a very worrying letter between two semesters, my exam results were on hold... Because of plagiarism.

This is presenting someone else's work as your own, I think I was and am a pretty decent software engineer, so I was a bit perplexed.  What was the topic, Data Structures?

This was a (looking back on it) rather inane module in my degree's second year and revolved around our implementing out own versions of the classic data structures, so yes list, linked list, map, doubly linked list and so on.  These were all really annoying things to write and 99% of sane people would today reach for the standard implementation of their chosen programming language than waste time writing their own.  I was very much of that opinion and well aware that C++ was receiving the STL at the time I had zero interest in implementing these things.

Luckily in 1994 when I began programming in Pascal there were no such data structures in Pascal, indeed I had written my own TPU in Borland Turbo Pascal with several of them in; and with a little fandangling I had them ready to hand in for this rather insane idea of a C++ based module.  Did doing this improve my programming?  No, did it teach me much?  No, it was all very old concepts and solved with code which was nearing four years old.

As you might image I didn't invest much in this project or module, I thought it would be an easy win.  Little did I know it would derail my belief in my whole degree course.

None of this is my embarrassment, no the embarrassment comes from the lecturer who reviewed the code.

For we were always encouraged to talk, swap ideas, swap concepts, and heck swapping four year old code solving for a very publicly already solved problem seems no issue, so long as folks understand where to source or have sourced a solution to the project I see no issue here.

This is after all the ethos of open software and open discussion in academia.

Unfortunately the lecturers, well they were solving for closed source, they were comparing like for like solutions and coming up with plagiarism accusations.

And this is embarrassing.  I look back at it and those lecturers, and they should have been embarrassed at the time and doubly so now.  They systematically stopped the whole cohort wanting to walk and exchange ideas, stunting our peer-review and inter-group working methods.  They picked on one of the strongest and most unique things about software and that was the concept of sharing it; and they should be ashamed.

How did they ascribe plagiarism?  Well, in the midst of my code was a very strange function... Here's the pseudo code:

boolean IsEven (value)
begin
    remove the 10,000's
    remove the 1,000's
    remove the 100's
   remove the 10's
   if ( equal 2 or 4 or 6 or 8 ) return true;
   return false
end

This is clearly weird and very odd and very much the thinking of a 16 year old who has no idea how else to do what he's doing because the "%" operator crashed his then only machine a 486 SX2 as it had no floating point co processor and the compiler he was using had no controls to stop the instructions being issued and he had no idea.

Fast forward those years and they present this code to me, and my first words are "Where did you get that from?"  And I told them exactly what this code did.

And you know what's more embarrassing?  The lecturer just said "why not modulo by 2" instead of asking WHY.

This is my overwhelming memory of my degree, lecturers who didn't ask why you had come to a solution, they had their concept of what their solution was and woe betide you if yours differed because you were marked down.  It was too much effort for them to think outside the box, too much effort to actually understand there was rhyme or reason in your solution.  No you were the student, they the lecturer, you learned from them very much not the other way around.

Its embarrassing to think how much that course was worth and how wrong it was in a lot of places; the few very good lecturers were often marginalized, or they were young and yet to be broken in.

Thursday, 28 April 2022

YouTube Advertising Standards in the Gutter

 I'm no prude, I quite like a bit of fun, but I do think that the YouTube advert algorithm is a bit poor; since I get censored for saying rude words and even a video of me IN A HOT TUB... yes Me... ME... In a hot tub talking got pulled....

But this is their advert....

Discover more eh?  She's not much more to reveal

And as you can see, it totally fits my stream of suggestions... (facepalm)

Saturday, 12 March 2022

Using Const Char* in Template

Compile Time Template Strings.... Yeah, these are a thing and I'm going to show you a live example of how to do them.  First lets take a moment to just understand what we want in some C++ pseudo code.

template<typename T>
T Square(const T value)
{
   return value * value;
}

const auto result = Square<int>(2);

const auto result = Square<double>(2.42);

In a template like this we can see this requires a number and more advanced writers might use SFINAE and type traits to ensure that the type is an arithmetic type, this would stop us doing something like...

const auto result = Square<"Hello">(2);

In this case we can not even compile, not because "Hello" is not operable with the multiplication, but that it's not that, the issue is that a const char* isn't allowed in the template itself.  You can't define a typename as const char*... Or can you?

Well, it seems you can in C++20.  The idea I had was to accept the template but treat it like a decaying length, copying the buffer in the template each step.  How could I do this?  Well, I need to compare the template somehow and determine the length of "Hello"... The buffer containing the data "Hello\0" itself is there in the code, what I needed was to think about how to treat that as type 6, the length...

The spaceship operator is what sprang to mind, but then I had the issue that the comparison result type wasn't known.... At least I don't know it, I don't know what string literal maybe being passed in, how to know it?  Well I didn't need to, I just return auto!

Here is the key code....  

  template<std::size_t Length>
  struct TemplateString
  {
    // Constructor is constexpr and simply copies the payload text
    // into the member data setup
    constexpr TemplateString(const char(&pPayloadText)[Length + 1])
    {
      std::copy_n(pPayloadText, Length+1, mText);
    }
    
    auto operator<=>(const TemplateString&) const = default;
    
    // Default is just an empty buffer of the Length+1
    char mText[Length+1] = {};
  };
  
  // Make decaying the template Length possible
  template<std::size_t Length>
  TemplateString(const char(&str)[Length])->TemplateString<Length-1>;


The template string is simply copying the buffer given locally, and the unwinding is stopped when the template length is met in the comparator.  I think this is a little strange, I may even be wrong (probably am) in explaining how this unrolling works.

However, what use do I have for this?

Well, my main use is in parameterising on the template the NAME of a thing... I have long seen code where the onus is on the engineer to put some static constant string into their derived class to allow some other feature to know what your class is called, or what it does.

Systems, Events, Services... These sort of things, general things that need a name for us mere humans all introduce this pattern of:

Base Class --> Derived Class :: sName

Where this sName is brittle, it can be forgotten, it can be mangled, it can be copy I paste... All sorts of issues with it.  I personally have my statemachine code up on github and I use an event within that, which could sorely use this very string trick... so I will be using it.

Lets take a look at the code in action on CompilerExplorer here.

And you can get hold of my personal example on github here.

As ever, if you liked this, subscribe on YouTube to let me know, comment below and if you use this trick feel free to buy me a coffee with the tip jar up top of this page.

Saturday, 26 February 2022

I wasn't Arxing You

I know of someone who will understand my confusion over what this Arx was, when WE are Arx...


I would guess this is the in-game currency or something, but I really have no idea.

You see "Arx" is the name of my guild, or corp, or really anything I play online, and has been since 2005.

So to see my favourite Latin word reused here, next to my name was really jarring... REALLY JARRING.