Thursday, 12 December 2013

Writing: The Ethical Programmer (Part 2)

My latest Becoming a Better Programmer column was published in the November CVu (25.5). It's the second part of my mini-series on The Ethical Programmer.

This instalment deals with our attitudes towards other people, and finally formulates our own Hippocodic Oath; the programmer's equivalent of the Hippocratic Oath.

Wednesday, 11 September 2013

Writing: The Ethical Programmer

The latest C Vu magazine from ACCU is out now. It contains my latest Becoming a Better Programer column. This month it's called The Ethical Programmer; the first instalment of a two-part series on ethics and the modern programmer. Gripping stuff.

This month, I look at our attitudes, at legal issues, and discuss software licenses.

To make the world a better place, you can enjoy a picture of some old rope, and a chicken. I also throw in some bad puns.

Monday, 24 June 2013

Speaking: Running Effective Rehearsals

I'll be speaking at The Worship Collective conference in Cambridge, UK on June 29th. This is an awesome event for musicians and worship leaders.

I'm leading a seminar entitled Running Effective Rehearsals. Obviously, this is a really practical subject, but I promise it'll be fun too. Hopefully there will be some practical wisdom to apply, and some encouraging advice to take away.

Monday, 13 May 2013

Writing: Bug Hunting

The latest  C Vu magazine from ACCU is out now. It contains my latest Becoming a Better Programer column. This month it's called Bug Hunting and, as you might guess, is about the art of debugging code.

This was inspired by conversations with Greg Law in the lead up to the 2013 ACCU conference.

Sunday, 12 May 2013

C++11: Iterating range-based for backwards


A few weeks ago we upgraded our toolchain with spangly new C++ compilers. Then we flipped the magical switch unleashing C++11 code features. This is a joyful apocalypse.

It's been fun transitioning to some of the new neater C++11 idioms.

Range-based for is one of the first things we adopted, largely due to the clear readability improvements it brings over tedious iterator type juggling.

Soon we stumbled on a shortcoming of range-based for. It allows you to iterate forwards with little syntax fluff, but not backwards. (We have many collections we "apply" by iterating forwards, and then "revert" by iterating backwards).

It's not too hard to iterate backwards in a reasonably readable way, by writing code like this:
for (const auto &i : backwards(collection))
{
    // ... use i ...
}
The simplest implementation of this is shown below:
template <typename T>
class iterate_backwards
{
public:
    explicit 
iterate_backwards(const T &t) : t(t) {}
    typename T::const_reverse_iterator begin() const { return t.rbegin(); }
    typename T::const_reverse_iterator end()   const { return t.rend(); }
private:
    const T &t;
};
template 
<typename T>
iterate_backwards backwards(const T &t)
{
    return 
iterate_backwards(t);
}
Of course, this is simplistic. It can be enhanced by making the class support C++11's move semantics, and allowing the wrapper function to return forwarded iterate_backwards. However, this wonderful new C++11 machinery serves to hide the simple intent somewhat, and doesn't win us much since this code optimises away neatly.

Perhaps there's a better way to do this? I've seen a few other solutions to this problem, but they don't read anywhere near as neatly, nor are they as straightforward to understand. I'm enjoying this new learning journey.

More iterator fun is to come...

Friday, 22 March 2013

Speaking: ACCU 2013

I'll be speaking at the ACCU 2013 software developer's conference in Bristol this April.

The session title is "Becoming a Better Programmer" (which you may have noticed has become a long-running theme with my recent work).

It promises to be a fun informative session with a few special guests and some twists.

As ever, this is set to be an excellent conference. You can check out more details on the conference website.

Tuesday, 5 March 2013

Writing: The Art of Software Development

The March issue of ACCU's C Vu magazine is out now. It contains my latest Becoming a Better Programmer column. This one is called The Art of Software Development. A little light relief for my column faithful.

Friday, 18 January 2013

Writing: Navigating a Route

The January issue of ACCU's C Vu magazine is out now. It contains my latest Becoming a Better Programmer column. This one is called Navigating a Route. It talks about how to learn a new codebase, navigate a routine into the system, and understand how to fix and extend the code correctly. It's a skill everyone needs!