Monthly Archives: April 2015

ACCU Conference Retrospective

I did plan to write a series of blog posts at the end of each day of the ACCU Conference in Bristol, but between having far too much fun learning, and having zero energy by the time I got home, never mind zero brain power, I thought I’d do a write up in one big posts with some “Match of the Day” style highlights.

Day 2 (Tutorial was day 1 for me…)

Day 2 kicked off with the ever energetic and lime-green nail coloured Pete Goodliffe bouncing around the stage giving a talk on how to become a better programmer. He covered various aspects of becoming a better programmer, but the main point I think he made was attitude. Our approach to becoming better. This challenged me (yet again! Thanks Pete (: ) because while I’d been moving forwards to becoming better, my attitude at times sucked!  Frankly.

Pete also issued a challenge to us all.  We were dared NOT to go to the stuff we’d be comfortable with, but to stretch ourselves and head off for talks that were way outside our comfort zones, and attend as novices. (Wasn’t hard for me, I was a novice at most talks!)  That way everyone would leave the conference having learned something they didn’t know before.

After being filled with coffee and all sorts of pastries and such, it was on to Seb Rose’s talk on Low fidelity approaches to software development. He spoke about how we tend to bite off more than we can chew, working on something that’s almost ready and will stay like that, and never get delivered.  He made a quick point on the waterfall and the biggest issue with it, was that everything feels ok until all of a sudden bang!

Seb also made the point that feedback is a very important thing to make use of, because it allows us to see where we’re at at the moment. It also gives us a chance to take stock of what we’ve done, and what our customers think. And pointed out that the Military use the Plan – Do- Check – Act which gives feedback that allows us to change the next part of the plan.

He quoted Father Ted, the scene involving Ted explaining perspective to Dougal making use of a toy cow to explain that this one was close, but the ones outside were far away.  And it’s the same with software projects.  Until we start working on something, we can’t understand the full scope of the problem we’re working on.

From there it was on to Mike Long’s talk on How To Talk To Suits, where I learned a great deal about speaking to business managers. And I thought I already did this pretty well, as I don’t like bamboozling people with technical jargon. This also included a practical workshop to work through which was good fun.

Mike spoke excellently on this, and talked us through a bunch of business clichés, such as a Business Case, where we need to present to someone for an allocation of resources for the stuff we want to do. Time is money, Mike pointed out that from a business perspective, Time matters more than money, indeed, I’ve often come across this in my career up to a point, “we don’t care how much it costs (within reason) but we must have it by tomorrow”.

Mike also used real world examples to explain that money comes in many flavours.  That is to say that if we wanted a new server for example, and our hardware budget was fully allocated, then we could STILL get the money but from another budget, such as an innovation budget for example.  Hence the term that money comes in many flavours.

There were some great lightning talks as well, and Chris Oldwood did some stand up which was great fun, and it’s a shame it wasn’t recorded, as there were some belters, who knows he may pop them on Twitter.

Day 3

Day three kicked off with frankly an amazing keynote talk from Axel Naumann on how CERN use C++. And it was awesome to hear how C++ was used to process data from the Large Hadron Collider. But what was epic for me, was to see some of the stuff that the LHC produced, and the fact that it was all completely open.  Axel also spoke about an experiment they’d carried out where they fired neutrons at nuclear waste that shortened it’s half-life but also generated energy!

Then there was an interesting talk from Kate Gregory and James McNellis on Modernising Legacy C++ in which they raised some excellent points. They made the point that we should compile C code as C++ as we’ll get better type checking.  They also made an excellent point that the warning you ignore isn’t a warning.  So Kate and James suggested that what we can do to modernise legacy C++ code is to do the following:

  • Increase the warning level and compile as C++
  • Rid yourself of the pre-processor.
  • Learn to love RAII (Resource Acquisition Is Initialisation)
  • Introduce Exceptions but carefull.
  • Embrace Const
  • Cast correctly

After that, there was an excellent talk by Chris Smith and Mark Upton from Redgate on what’s wrong with sprint retrospectives and how to fix them. This was a very practical talk, where we there was a fair bit of user interaction where we shared our experiences of working using retrospectives. They shared their experiences at Redgate in improving their retrospectives and had a lot of good ideas I plan to put in place at work.

Day 4

We were treated to a great opening talk where Alison Lloyd went through some case studies of various mistakes made in industry and what we could learn from them. I was scared that there’d be photos of Therac 25 victims initially, however there wasn’t anything like that.  Alison started her talk with a sobering discussion about diarrhea and how it caused so many deaths. It was quite educational and challenging to hear the devastating effect that this had on humans, and HOW it caused so many deaths as well.

This talk was running through my mind for most of the day if I’m honest, and I’m pretty sure I’m not the only one who was challenged and moved by what I heard in those opening 15 minutes.

Day 5

I had the unfortunate experience of turning up to a talk, and needing the loo, popped out for a second or two.  When I came back the door magnet engaged, so I couldn’t get back in. I didn’t want to knock either as I didn’t want to disturb the chap giving the talk.

However, Anthony Williams’ talk on C++ Atomics was very good.  I didn’t understand all of it, but I certainly got the gist of what was being said.  Essentially, don’t use atomics unless you have to.  You should only use them if you REALLY need the performance gains it will give you, and even then you should only use the memory_order_seq_cs (Sequential Constant) as the others are horribly complex, and you should only use them if you REALLY know what you’re doing.

There was a spare slot on the Saturday, so I volunteered to fill half of it with another chap, the only issue was, Roger and Kevlin were also speaking, so I knew that most if not everyone would be at one of those two talks, so I expected nobody to turn up to the talk I gave. But two guys who’d turned up to the previous talk stayed.  So rather than me stand up and do a talk, I made it more informal and turned it in to a chat with slides which I think quite well. I’ll be honest, I knew there wasn’t going to be many folks at this one, but it was a good way to see if I could do this conference talking thing.

The End-note was Chandler Carruth from Google talking about how they’ve made C++ safer, easier and faster with their use of Clang. It was a great talk with some live code demoes as well. He told us how Google had a completely unified codebase which allows for a single unified build system.  Chandler also spoke of the things that made C++ safe and quicker as well but I wasn’t quick enough to grab these as notes, the slides should be available though.


I’m not sure if it was me or not, but this conference felt different to me. It felt like I connected more with the material and the topics, and that could well be due to the fact that I’ve developed as a programmer since the last conference. But there was a pleasing and friendly atmosphere this year, not that there wasn’t one before but it felt more tangible this year at least for me.

I also had the chance to make new connections as well as catch up with those I made connections with last year, and a lot of people came up expressing an interest to be interviewed for the CVu magazine, and those I approached to ask were equally as nice.

I was sad to hear that Jon Jagger who’d been conference chair for the last four years had stepped down. I’m certain that I’m not alone in saying that Jon’s arranged an amazing conference this year as he has done for the last four years, and the fact he got a full minute of applauds and cheers speaks volumes for how good a job he’s done. I do look forward to hearing him speak next year though (:

However Russel Winder is the new conference chair, and I know that the conference is in safe hands.  So I’m excited to hear of what’s going to come in 2016, I may even put in a paper this time Winking smile

If you want to see what went on and who said what, the slides are available at the ACCU website, which can be found at and if you like what you see, then consider becoming a member 🙂


ACCU Tutorial Day 1 Review

So it’s April, which means the ACCU Annual Conference is here, and it was off to Bristol with me to attend the pre-conference tutorial. The original tutorial I’d registered for had been pulled, as the speaker (name here) has been seriously, so I wish him a speedy recovery and hope to hear his tutorial next year if he gives it. So I had to change my tutorial to attend, so I chose Kevlin Henney’s Raw TDD.

It was an excellent talk, the first portion Kevlin presented on the various facets that make TDD what it is, as well as define what TDD is and what it isn’t.

After lunch,using Jon Jaggar’s excellent cyber-dojo, we practiced developing using a pure Test Driven Approach. And Kevlin was very strict on this as well. And it was quite a challenge. I must confess I thought what I did at work day to day was TDD, but it turns out I have GUTs, (Good Unit Tests) rather than use a pure TDD approach.

After we’d switched coding partners a couple of times, we started to write our own Testing Framework. Now there are many excellent frameworks out there, so Googlecode has nothing to worry about at the moment, but it was awesome to see how relatively easy (albeit with a fair ammount of knowledge) it is to write your own unit testing framework.  Ours was based off the assert test and we built upon it.

All in all, it was a very enjoyable day of learning, and as ever Kevlin’s style of delivery was it’s usual energetic, engaging and enthusiastic self.

As a side note…

If you’ve never been to the ACCU Conference before, I’d strongly recommend going. It’s a world-wide gathering of C++ programmers, and in the past we’ve had talks given by Bjarne Stroustrup, Scott Meyers, Uncle Bob Martin, Michael Feathers and many others besides.

Also consider joining the ACCU.  It’s a great organisation, and it doesn’t cost all that much to join. And it has an awesome community of people. And if you’re a member you get a sizable discount on the conference, so double bonus (:

Out with the new!

Before I became a C++ developer, I wrote a lot of Java, and I mean a LOT. When I was unemployed I wrote a point of sale system, a stock management system a web servlet app. I wrote pretty much everything in Java back then.

Then I learned C++, and I didn’t know that you could write C++ in a Java fashion.  Indeed my mentor at the time saw some code I wrote and just like a Java developer I put everything in one file within a class.

And wouldn’t you know it, now I’m the mentor and I’m finding my mentee is doing the exact same thing. And some may say why is that bad? It all has to do with a simple word. And that word is, new.

In Java if you wanted to create an object, you’d do something like this:

static void main(String args[])
    Person fred = new Person();

This looks all nice and dandy doesn’t it.  You simply create a new person object, and then forget about it. Now I want to point out that in Java, this IS NOT a bad thing. Java has a special mechanism to deal with this called Garbage Collection, which is something that runs periodically and checks for objects that have not been used, or since gone out of scope and deletes them.

However, C++ doesn’t have this feature. (Well not as such, but it’s beyond the scope of this blog post). C++ is a very powerful language, and it trusts that you know what you’re doing and this is true of object management.

C++ doesn’t clear down objects for you, you’ve got to do that yourself. In C++ for every, yes EVERY object that’s created with the keyword new, there MUST be a corresponding delete for it.

So consider the following code:

int main()
    Person* p1 = new Person();
    // now we're done with the person object.
    delete p1;

The above code not only creates a person object, but also deletes it.  An important thing to learn also is to delete things in the reverse order you create them. It’s considered good practice, and can prevent possible undefined behaviour.

The other thing new does, is that it creates your object on the heap. “So what?” I hear you ask. Well, let me explain a little about why this isn’t ALWAYS what you want…

A very quick note on stacks and heaps…

When you write a program, it can be stored in one of two places in memory. The stack, and the heap.

The stack is memory that’s allocated for a thread of execution. So for example, when your function is called, a block is reserved on top of the stack for local variables and some data pertaining to your function. When the function returns or hits the last brace, the block is then freed automatically and can be used for another function. Imagine if you will a stack of plates in a cafeteria, a memory stack is identical. Last one In, First one Out otherwise known as LIFO. So the most recently used block is always going to be the one that’s freed.

Stacks don’t tend to be that big, so you wouldn’t want to put a 512Mb vector on there for example. That’s what the heap is for.

The heap is a chunk of memory that’s allocated for dynamic allocation. There’s no enforced pattern like there is on the stack, on the heap you allocate your data pretty much where you want, as long as it’s contiguous space big enough to hold your data.

This is where your data is put when you use the new keyword in your code, and if you don’t call delete on your new’d object, then it will stay in memory thus swallowing up some resource.

So what are the options?

Now that we know where new’d objects go, what are the alternatives?  Well you can create stuff on the stack, however as previously mentioned, the stack isn’t as big as the heap. So we must be judicious in where in memory we place our objects. So for example, if you have a class object that you know is going to have a massive vector of objects in it, then place it in the heap using the new keyword.  Otherwise, put it in the stack.  One of the main benefits of this approach is that you don’t have to worry about deleting it, because as soon as your function hits the last curly brace, it’s popped and released from the stack.

To place something on the stack you’d do the following:

int main()
    // let's say that we have a person that takes a string as it's constructor
    // argument, you'd declare it thus:
    Person student("Joe Bloggs");

    // For a default constructor with no params you'd do thus:
    ConfigurationManager config;

Both these place objects on the stack rather than the heap.

Another option available to you, if you use a modern compiler (and why shouldn’t you?) is the use of smart pointers.  These have been around for some time now, but they almost (I’m not 100% sure) act like an object created with the new keyword in Java in that the second they go out of scope, their destructors are called and the object is destroyed. Now while this may sound similar to garbage collection, I’m reliably informed that it isn’t.

However there are a number of smart pointers that can be used.

unqiue_ptr is a smart pointer that holds sole ownership of an object via a pointer and will destroy it once the pointer goes out of scope. You can’t have a uniqe_ptr pointing to two objects. The code sample below shows a very basic demo of unique_ptr.

class someHugeObject
    // a whole bunch of functions in here....
    void someFunction();

void doSomethingWithObject()
    std::unique_ptr<someHugeObject> huo(new someHugeObject());
}  // then huo is deleted when we get to this line.  Even though we've used the new keyword.

shared_ptr is, as the name suggests a pointer that allows you to have multiple pointers pointing to the same piece of memory. So you could have many objects sharing the same block of memory. But unlike a unique_ptr, the object is destroyed under the following circumstances:

a) The last remaining shared_ptr owning the object is destroyed or b) the last remaining shared_ptr that owns the object is assigned another pointer

std::shared_ptr<Person> p1(new Person("Fred Jones")); // we create a new person
std::shared_ptr<Person> p2 = p1;  // now p2 has access to the person in p1

// so if we do:
p1.reset();  // the Person will still exsist because p2 is still pointing to it.
p2.reset();  // the last reference to the memory block has gone, so it now gets removed.

So in conclusion then, I can still hear my mentor’s words in my ear when he told me that I should never use new. And looking at this, you could say there’s a strong case for not doing so.  However I’d like to say:

Use the stack when you can, but when you need to, use the heap.  Also don’t be afraid to play, spool a VM, have a play, cause a stackoverflow and see what happens. It’s the best way to learn.

Happy coding people Smile