Tuesday 18 December 2018

Are Code Reviews Waste?

I cross posted this post on Medium.

"Waste" is NOT a Dirty Word

My recent talk Agile is a Dirty Word generated a lot of interest at the conference at which it debuted and on social media since. More, in fact, than I ever thought I would get for any of my talks. One of the themes I examined in this talk was waste. This came quite early in the piece and one of the points I was making is that (unlike Agile, Kanban and various others) "Waste" is NOT a dirty word. What I mean by this is that whoever the client is (in my experience at least) and whatever stage of Agile maturity they are at, "Waste" is a concept that people understand and want to reduce.

An "Innocent" Value Stream Mapping Slide

I wanted a way at my client to convey how certain activities don't add value to the business and should therefore be considered to be waste. The slide I came up with for the client was designed to illustrate a very simple value stream map and start a conversation over which activities add value and which are waste. I reused the client slide with only a change to the title in Agile is a DirtyWord. Here is the slide as used in Belgium:


I use the word "innocent" in the title of this section because, as is usually the case, nothing on this slide was ever accidental or innocent. When I originally showed this slide to our client (it has transitions that make parts of it more obvious) I knew that "CODE REVIEW" down in the waste part would be controversial. I knew that several people at our client were obsessed with the idea that code review was an important part of their delivery process. So whilst "code review is waste" was not the title of this slide when I showed it at the client, I very definitely wanted somebody to notice it was flagged as waste and challenge it. This did indeed happen which "coincidentally" let me introduce the subject of why we think code review is waste in the course of talking about something completely different.

What is Waste?

In the rather simplistic model above, I have a notional timeline for a story moving across a wall. We have to assume that the thing that is moving across the wall is valuable. That is to say, I'm assuming that some sensible work by a product owner or similar has taken place and we are confident that when this thing gets released in to production that it will return some value to our company. Note the key point here is that when this thing gets released to production it will return some value to our company - NOT BEFORE. So the clock starts ticking from the point when the story's value statement is articulated and ends when it is live in production. During that time, anything that doesn't help the story move along the wall is waste.

What Outcome is Supported by a Code Review?

One question that we often ask our clients is "what outcome does this process support?" Sometimes you can ask this question of a particularly silly piece of risk management theatre and it can provoke anything from mystification to ultra defensive cat-bear-trap response to complete silence. All three responses, by the way, are a great sign that the process being questioned is unconnected to any real outcome and thus devoid of any value. When it comes to asking this question about code review, however, I've generally received a response along the lines of "code review ensures good code quality" or "we need to check that the code works". So assuming such a response is offered, we can't argue the thing away on the grounds that it can't be linked to a desirable outcome, since "working code" or "code quality" are both outcomes we should be looking for. So why do I argue code review is waste?

What REALLY Happens in a Code Review?

Disclaimer: I am writing this section based on my own personal experience. If anybody has worked in a situation where better things happen with respect to code review I'd love to hear how those better things can be made to happen.

I would also add that all of my comments refer to an organisation where the team is co-located or at most distributed over two sites. I am not considering an entirely distributed team.

The Process

Usually, a code review is requested by a developer when they want to merge some changes into a mainline. This results immediately in the request for code review waiting in a notional queue somewhere for somebody to act upon it. This is undeniably waste, all queuing time is waste, I don't think there is any argument on this one. When somebody "picks up" the code review all they can typically see is the changes made to the code. Depending on the diligence of the reviewer or, more likely, whatever time they perceive they can spare from their "real work", they might fire up their code editor and view the code changes in the wider context of whatever code base it lives. They then annotate the changes (using whatever tool they use) with any suggestions for improvement and update the status of the code review to something like "suggestions for changes made" or whatever the workflow tool in play dictates. At that point the review goes back on the queue of the person who requested the review (more undeniable waste), they react to the suggestions as they see fit and then the cycle repeats until the code reviewer "approves" the changes.

The Comments

Again, I repeat my disclaimer. There are two types of comments that I have seen. The first type are utterly unrelated to anything the code does at all. An example of such a comment would be "We should put opening braces on the same line as a function signature, NOT the line below", or one of my particular favourites "You have used a tab character of width 3, instead of 3 spaces, for your indent" (how did this person even spot that?) These type of comments are not only entirely devoid of value whatsoever, they are irritating, probably passive aggressive (I'm still never quite sure exactly what PA means but I think it applies here) and DEFINITELY should be caught with whatever linting tool is play.

The second type of comment I have seen would be along the lines of "you used a for loop to iterate when you could have used foreach" or "this slightly different way of doing it will be more efficient". Whilst I have slightly more sympathy with this type of comment I still don't think it is worthy of note unless there is specifically something about the implementation that is "wrong" or would be likely to cause some kind of real performance issue.

A Useful Comment

A useful comment could be something like "the tests don't cover all the edge cases" or "There should be an integration test of this thing". I have never seen this happen. Why? I think the answer is that the reviewer lacks the context of the story that was played and therefore lacks the knowledge to make any really useful comments about actual functionality.

Does Code Review Support the Suggested Outcomes?

If we assume that the types of comments that get passed around fall under the not useful categories mentioned above then I struggle to accept that code reviews do anything to support the outcomes of "good code" or "working code" and I would therefore argue that all such process is waste.

What If the Comments are Useful?

This is the tricky part of my argument. I have had some people argue that there are useful comments in the code reviews that happen at their company. As I say, I have never seen this in any review that I've been involved in but I'm prepared to accept that it can (and probably does) happen that some useful comments are sometimes added to code reviews and acted upon by the original developer. Is such a code review waste?

I believe it is still waste. Why? Firstly, the queuing time is there, whatever you do. Secondly, there are at least two context switches involved for different people to support this process. Context switches are expensive and add no value to any process. So they are waste. Thirdly, there is a better solution to the outcome of "good code" and "working code". Both of these outcomes are more easily achieved through pairing or mob programming and you get shared context and therefore better bus factor, into the bargain. Perhaps, if the outcomes actually are being legitimately supported by a code review process then I should downgrade my claim from "code review is waste" to "code review is an anti-pattern". I think that may be semantically more accurate in this case but "waste" is somehow more tangible a thing to eradicate than "anti-pattern".

Can Code Reviews be Value Adding?

I mentioned above that certain code reviews might be arguably an anti-pattern rather than straightforward waste. I'm prepared to accept that they add value if the following things are true:
  • Instead of the workflow, with all the queues mentioned above, the developer requesting the review approaches other developers until she finds somebody available to help with the review.
  • The code review is carried out together between the developer and the reviewer. All suggestions are therefore discussed and collaboratively acted upon.
  • Assuming there isn't the need to do any major extra work (perhaps after sharing the context it becomes apparent that the suggested solution just doesn't do what it is meant to do) the pair will continue until they are satisfied with the result and they will then merge the changes as part of the workflow.
According to the authors of Design Patterns, an anti-pattern has the following characteristics:
  • A commonly used process, structure, or pattern of action that despite initially appearing to be an appropriate and effective response to a problem, has more bad consequences than good ones.
  • Another solution exists that is documented, repeatable, and proven to be effective.
I think I have argued that in general code review fails in its goals and thus fulfills the first part of the definition. I strongly believe that there exists at least two better solutions - pair programming and mob programming. So it is therefore my contention that code review is at best an anti-pattern and at worst (and this is the more likely scenario in my experience) waste.


Saturday 8 December 2018

What are Memes and why Should I Care?

What are Memes?

The Modern Social Media Version

In recent years, certainly since the explosion of the Internet, and more particularly of social media, the definition of "meme" seems to have changed somewhat. Now, a meme seems to be understood as being something, usually trivial or somehow amusing, that spreads virally across the Internet and refers to some aspect of popular culture. Usually these memes are picked up and altered slightly by each user to fit a new context or to slightly modify the joke. Eventually, if the meme proves popular or durable enough, it can end up having a version of itself on a site like  Meme Generator which allows anybody to quickly and easily propagate the meme within their own social network.

Examples

I myself am not averse to jumping on any memetic bandwagon. I can think of at least two memes that I have been guilty of propagating at one time or another.

Disaster Girl

This one has to be my all time favourite. Probably because the original picture reminds me of one of my daughters. Oh, but for the grace of god, fire-department-safety-demonstrations and the fact that this happened before Felicity was born, she could have been disaster girl...

I suppose 305,000,000 hits on Google shows the reproductive power of this one.

XZibit

I like this one too. I came across this one while I was working on a project for ThoughtWorks. I, of course, had never heard of XZibit (he's a rapper) but apparently this derives from a TV program called (I think) "Pimp my Ride", hosted by XZibit, in which the car of a member of the public is customised or "pimped". I think I have seen a British version of this program.


Only 6,330,000 hits for XZibit, nowhere near the league of Disaster Girl but still a healthy reach. Interestingly, the meme is more popular than the person it seems beause when I Googled for XZibit I got 5,120,000 hits. The above search was for XZibit Meme.

What appealed to me about this one is that it is supposed to be somehow recursive. When I had that expained to me I was all over it, even without the popular culture knowledge to support any understanding of how it originated. I think this may speak to the intrinsic "value" of the meme and its ability to reproduce itself. I'll come back to this idea later. I used this meme when I found out that defmacro in Clojure was itself a macro.

The Original Definition

I have recently finished reading The Beginning of Infinity by David Deutsch. I thoroughly recommend it if you haven't read it. The central theme to the book is knowledge, what it is, why we acquire it and how we acquire it. One of the things that is returned to more and more as the book goes on is memes. What they are, why they are important, how they are sometimes useful and how they can be damaging.

The word "meme" was coined by Richard Dawkins in his 1976 book, The Selfish Gene. He uses it to refer to an idea that replicates. I haven't read this book at the time of writing and I'm therefore using the definition of meme that I got from Deutsch. The interesting argument is that there are ideas that can replicate through people and culture sometimes without showing any obvious benefit or advantage to the host for the idea. So a meme is an idea that self replicates. That is it. Apparently Dawkins was surprised that his idea of "meme" became something that lasted so long and (I assume due to semantic diffusion) took on so many different forms.

Examples

According to the Dawkins definition memes can take many forms. Some are useful and certainly convey value to the thing that propagates them. Some are most definitely sub-optimal in many respects and seem to somehow persist despite their lack of obvious value.

In the animal kingdom an example of a useful meme could be the way that apes can translate the knowledge of how to use tools, such as stones, for a specific task, such as breaking nuts, in a way that is useful to the recipient of the meme.

There is a much richer set of examples to choose from in the human species. The distinction that I want to examine further is that of rational memes v anti-rational memes. There isn't a great deal of time given to why anti-rational memes evolve originally in Deutsch's book, instead it concentrates on how these memes persist and replicate. An example of an anti-rational meme given is that of racist behaviour within sub-cultures inside a largely rational culture. There seems to be little value to the host in holding such views, or of propagating the racist meme to another host. But it certainly persists as do several other memes that present as irrational prejudice.

Memes in Business

So if we assume that the definition of a meme is an idea that somehow has the ability to replicate then why am I writing about it? Well... As I read The Beginning of Infinity there were a few places in the book that made me think about some of the clients I've worked for. To summarise what I read, Deutsch postulates that anti rational memes can exist in society and can be a reason why societies are static societies as opposed to dynamic, learning societies. A static society is characterised by an aversion to new ideas, suppression and possibly fear of new ideas. A dynamic society that encourages criticism of ideas and assumed knowledge is much more willing to abandon its memes or take on new memes as reasonable criticism may demand.

The Corporate Immune System

The corporate immune system is a real thing. I've seen it in many different places and I've seen its destructive power. In a modern (aspirationally) agile business, the corporate immune system is the very antithesis of agile values and mindset. I have previously speculated as to how it evolves and have read several theories. I think memetic, self replicating knowledge and behaviours could be part of this reason. Risk aversion and the corporate blame / hero culture are very much responsible too but perhaps those things are themselves memes?

Risk Management Theatre

I have previously written about Risk Management Theatre and in particular how it can comprise many behaviours and processes that just don't make sense now (even if they may have done originally). Something makes these behaviours and processes persist. Is this some kind of memetic groupthink?

Perhaps this is exactly why risk management theatre has a power to persist beyond which any rational thought (at least that I have previously considered) should allow. But when I think about this new understanding, for me, of what a meme is and what memetic knowledge is it begins to make a bit of sense. I mentioned earlier that I propagated the XZibit meme without ever having an understanding of its origin. Is this similar behaviour to what I see within an enterprise where new staff carry on the by now irrational behaviours just because that is the way it is done?

If we go right back to the dark ages or earlier, when most societies were tribal, it probably made sense to be suspicious of people who did not come from your tribe. It could have been a sensible precaution for there to exist a cultural meme which caused distrust of people that were not from your tribe. It clearly doesn't make sense any more. So perhaps this meme that was once rational is now anti-rational. But does it still exist in the 21st century in otherwise rational societies as the remnants of this earlier meme?

So my question is, is risk management theatre as powerful and hard to destroy as it clearly is because we, human beings, have an inbuilt mechanism to recognise, (rationally or irrationally) value and propagate memes? Is a risk management theatre process a meme that was rational at its inception, has become anti-rational, but still maintains its power to reproduce itself and live on in the enterprise? Does it not even matter to people hosting the meme that they have no idea of its origin or its original value? I don't know the answers yet but I'm going to continue to ask the question.

Thursday 6 December 2018

More Devoxx, More Talks

Three Conferences in November

I already blogged about Devoxx Belgium. That was a few weeks ago now. The week after that, on Thursday November 22nd, I flew out to Kiev for Devoxx Ukraine. The conference was on Friday 23rd and Saturday 24th, I flew back on the evening of Sunday 25th. 

After a couple of days recovery at home, I flew to Marrakech for Devoxx Morocco early in the morning of Wednesday 28th November. I was out of bed at 4:30AM for a 5:00AM taxi. It was (almost literally) a flying visit. I got to the hotel in the early afternoon, had lunch, walked to the conference venue, had a look around, met a friend, walked back to the city, had a look around, had dinner, found what seemed like the only place in Marrakech that served beer, had a couple, went to bed, got up, went to the conference, did my talk, saw my ThoughtWorks colleagues talk, had a quick beer with them, got a taxi to the airport and flew home. I got back home around 1:00AM on Friday November 30th meaning I had been out of my house for only 44 hours. Not surprisingly I was somewhat tired.

So in three weeks in November I presented 6 talks at 3 conferences in 3 very different locations. At the time of writing Devoxx has published the videos from Belgium and the photos from Belgium and Ukraine. I thought I would commit some of the highlights to this blog.

Belgium and 900+ People

I already wrote about Devoxx Belgium and posted a selfie from my talk Agile is a Dirty Word. While I was in Ukraine I had a chat with Stephan Janssen, the founder and owner of the Devoxx conferences, amongst other things about how the new Devoxx websites and apps work. In Belgium, Alasdair Collinson had postulated to me that the Devoxx app was reassigning talks to rooms based on the number of likes that people had given the talk synopsis. He therefore speculated that my talk had been moved from one of the smaller rooms to the largest room in Antwerp. Stephan confirmed that this speculation was indeed correct. As my talk had in excess of 3x the next highest talk scheduled at that time, it was indeed moved to the biggest of the 8 theatres. He further went on to tell me that there were 850 seats in that theatre (I had it at around 300 - 400) and that he estimated that there were in excess of 900 people watching given the number of people that were sitting in the aisles.

Here is a picture of me with part of that audience and the MASSIVE screen behind me...

Just to keep my feet on the ground, here is a picture that they smuggled of me when I was finding the only quiet place in Antwerp to have a remote meeting with some of my ThoughtWorks colleagues on the Wednesday afternoon:

Some Kind of Weird Dance

I never script my talks. I use the slides, which have been occasionally (and quite fairly I think) been criticised for being too wordy, as the basis of starting the conversation that I'm going to have with the audience about the subject that I'm raising. One side effect of this is that each time I present a talk it is different and I can't guarantee that I'm going to say the same things or emphasise the same points. Sometimes it goes off on weird tangents. I haven't watched the whole of the video from this talk yet but when I do, one thing I'll be curious about is what, exactly, I was doing when these photos were taken:




The mind boggles...

Devoxx Ukraine and 3 Talks

From the outset I was set to present two talks at Devoxx Ukraine. They were What Drives Your Development and Are Quantum Computers Really a Thing? (quick disclaimer, these videos are not from Ukraine because at the time of writing the Ukraine videos weren't available). After the success of Agile is a Dirty Word in Antwerp, I noticed that there were a handful of sessions in Ukraine that were TBC so I sent an email to the organisers directing them to the video from Antwerp and suggesting that I would he happy to present this talk again. They duly scheduled me as an added bonus. So three talks it was in Ukraine!

Diversity

One thing that was noticeable about Devoxx Ukraine was a distinct lack of diversity. Of course the IT industry is notoriously male-centric but unfortunately Devoxx Ukraine was almost a female free zone. There were almost more female speakers than attendees. Not the fault of Devoxx of course, it just goes to show that some parts of the world haven't moved on as much as others.

The Trip to Chernobyl (nearly)

The conference kindly organised a trip to visit the Chernobyl reactor on the Sunday morning. Prior to the trip we had to submit our passport details to satisfy some kind of security protocol with the Ukrainian authorities. Whatever the security checks are (and I assumed them to be some kind of security theatre) one, or perhaps more than one, member of the party was declared persona non grata by "the authorities". So on Saturday morning we were told that the trip was cancelled. Apparently if one person in the group is considered unacceptable then none of the group is allowed to visit. At least that left us free to enjoy Saturday evening as it meant we no longer had to meet in the hotel lobby at 6:30AM to get a coach to the site of a nuclear disaster.

Some Memories from Kiev

I cropped this one and used it as my new profile photo in various places.

I didn't realise there was a telly with the slides on it. I could only see the thing behind me.

There was a laser lattice thing on the way in to the conference.

There are lots of yellow buildings in Kiev including this rather wonderful cathedral.

And some rather less impressive looking architecture. I was particularly perplexed by the way this 1980s-(presumably Soviet)looking-grey-building thing appears to be sort of glued on to the rather pleasant yellow building next to it.

Here is my ThoughtWorks colleague Aiko with me as we were on the main stage with the other speakers during the closing ceremony of the conference.

And finally here is the picture of all the speakers on the stage at the end.

Summary of Devoxx Ukraine

Another great conference from Devoxx. Very well organised but Ukraine must try harder on diversity.

The Last Leg - Devoxx Morocco

I was truly exhausted even before I flew to Morocco. Given the swift in and out nature I didn't get to see much of the conference. It was a lot smaller than both Belgium and Ukraine but, somewhat surprisingly, extremely diverse by comparison. There was apparently around 30% female attendees where both Belgium and Ukraine were under 5%. Probably this is up there with the most diverse of conferences I've been to. My guess is Agile on the Beach or Lead Dev in London have the highest proportion of female attendees that I've known but I have no data to back that up. 

My only talk in Morocco was What Drives your Development which was being wheeled out for the third consecutive week. It went down pretty well again, this time without the time honoured Martin Fowler from Eastenders joke. I decided that since that joke falls flat in Western Europe and Eastern Europe, in fact anywhere other than the UK, it would almost certainly fail in Africa!

I didn't realise that the snow capped Atlas Mountains would be visible from Marrakech.

I saw this cat in the city centre. A cat with markings that look like a heart! My daughters love this cat and I will surely work it into some presentation somewhere. I have to, Woody Zuill told me that you should always put at least one cat slide in every presentation...

The square in the old part of Marrakech is quite spectacular at night.

My colleagues Oli and Monira presented this talk in both Belgium and Morocco. I missed them in Belgium as they were talking on the Friday and I was gone by Thursday evening.

And thus ended my November World Tour of conference speaking. I have nothing more planned until January, which is Snowcamp in Grenoble. For now, back to the harsh realities of working for a client, if only I can get staffed somewhere...