Friday, 6 January 2017

The Agile Architect

It seems to me that we all have an understanding of what Agile development and Continuous Delivery are, but we're generally less clear on how the role of Architecture fits into this picture. Most of the Agile frameworks fail to mention architects at all, and hence many companies consider architecture to be something that's done "before you get to the Agile bit".

Recently "Evolutionary Architecture" and "Continuous Architecture" have been talked about a lot - techniques which require buy in and alignment throughout the organization. Here's what I've learned about what agile architecture can be done at the coal face in companies where these ideas aren't fully embedded.

1. Individuals

We still have this idea in the commercial world that the software development process is something like a factory conveyor belt, and Kanban (excellent though it is) sadly reinforces this idea.
Development as a conveyor belt
Software delivery shouldn't be a conveyor belt.
It encourages high WIP, and low collaboration.
Two decades of Agile still haven't broken the notion that first this person does this, then that other person does that. Those people have specific roles, with job descriptions.

But in the real world, teams are made up of people, not roles. People aren't designed and built to adhere to precise job descriptions - they're complex, nuanced organisms with a range of abilities, needs, experiences, and motivations.
For example, the skills and characteristics required to be a BA and those needed to be an engineer are not mutually exclusive. Similarly with architects or testers. People typically have a variety of experience and knowledge - why should we restrain them?

My point is that we shouldn't be prescriptive about what a team looks like. And in the particular case of architectural design, I'd argue that it's not something that only an architect can do. In fact, the designs that architects produce often come (and should come) from the subject matter experts - engineers, testers and so on - who know the details of how it all hangs together, and will be able to identify many of the complexities and edge cases from the outset. 

2. Working Software

The traditional idea of Big Design Up Front, and an Architecture Team in their ivory tower is much derided, and rightly so. However it's still a reality in many companies over a certain size.

As any software developer will tell you, you can't design code up front and expect it to look like that when you're done. You discover things as you go along; the exact design emerges as you proceed, finding your way along, sometimes going back and refactoring when you perceive a better way of doing something. I still shudder when I remember an architect I once worked with whose idea of architecture was to produce UML class diagrams with literally dozens of classes and interfaces, to throw over the wall to the development team.

Most people would agree that architects should work at a high level. However, if they're not involved in the actual implementation of the things they design, they'll never learn about the implications of their decisions at the coal face of development and operations, and will make the same kinds of mistakes over and over again, with other people picking up the pieces.
So architects should operate at a high level, but strive to understand the low level details - which in practice means being involved with the team right the way through implementation and beyond.

If your company thinks that they can be much more efficient having architects working solely on the "initial design phases" of projects then they're mistaken - they should take a long hard look at how smoothly "implementation phases" typically go, and the quality of life of their Ops and Support folk.

Another important aspect here is that if your company is project focused (which is sadly usually the case) rather than product focused, then there may be the temptation to have a High Level Design Phase "before you get to the Agile bit". There's probably a lot of variation in what people understand by the term "High Level Design", so let me just say:

- You do need to understand the bigger picture, so by all means produce an HLD. But...
- No design work should take more than a day or two. If it does, you're trying to bite off too much scope, or too much detail. 
- I prefer the terms "High Level Approach" for the bigger picture stuff, and "Design" or "Elaboration" for the specific design work needed for a ticket. 
- Aim to do all design work just in time. This is in order to avoid waste, and gain and maintain momentum.

3. Collaboration

The role of an architect is, in my view, the technical role that can least afford to operate in an insular way.
There are broadly three types of collaboration which are pretty essential to be effective as an architect:

  1. Identify and build relationships with all the stakeholders for a particular change (Marketing, Ops, Product, Technical Support, Service Desk...) to make sure that as many aspects as possible have been considered, everyone's aligned, and there are no nasty surprises for anyone later on (including you, if an unexpected requirement or constraint pops up at the eleventh hour).
  2. Brainstorm, refine, and choose a technical approach in collaboration with the team that will actually implement it.
  3. Get your decisions and design ratified with all the stakeholders. This is the scary bit. As an architect, your work will be scrutinised and critiqued more widely than anyone else's (except perhaps UX and front end designers, poor bastards). If it's not, then I'd say you're not doing your job properly.

That last point is probably the most important. By communicating and justifying your designs, you're forced to discover exactly how well you understand them, and how well considered they really are. Basically: Talk to people.

4. Responding to Change

This is always contentious, because no one likes change. Especially when you've slaved away on something, only to find that you have to take 2 steps backwards and redo it now that someone's changed the requirements, or the priorities.

However, as we all know from bitter experience, change is absolutely inevitable. And the answer given to us by all Agile frameworks is: Keep it simple, and keep it small. That's because simple, small things are easier to change than complex or big things.

This poses an interesting challenge for an architect, whose responsibility is usually to produce some kind of design not piece by piece, but for the design as a whole. And that's why I'd suggest that architectural designs should have two important features:

  1. Be simple
  2. Be modular
So we're talking clear separation of concerns. Loose coupling. Avoiding over engineering - remembering what XP (my favourite of the Agile frameworks) taught us about YAGNI
Designs should be embarrassingly simple: People should look at them and instantly understand them. People should say: "What the hell do we pay this architect guy for? This is obvious!"
(I have a blog post brewing on how we should define and evaluate the effectiveness of people and teams, but here's a spoiler: It shouldn't be how complex and clever we make things).

Blindingly obvious things get overlooked all the time. An architect should be one of the key people making sure that doesn't happen.

5. What not to do

So I tried to structure this post around the four main tenets of the Agile Manifesto, but I'll close by just listing some common ways that architecture is often done which are inherently not Agile:

Separate Architecture Team

This is born of the misguided notion that design is a finite activity, done at the start of a project. Instead: Embed your architects in the teams where the work will be done. Otherwise:

  • They'll be making decisions they don't understand
  • The team won't understand or embrace the vision
  • The team's unlikely to have any respect for the architect.

Formal architectural governance

I'm not saying you shouldn't do this - nobody wants to use an Internet Banking application where no one confirmed compliance with ISO:IEC 27001:2013.

But if technical decisions have to go through an Architecture Steering Board, made up of senior techies who, at a distance, make decisions about projects, grant dispensations to "divergence from the original designs", or document "corrective actions" to go on a "programme register" etc. etc., then people simply won't bother. People will work around it.

Better to trust the people we employed to actually know what they're doing
(Test things - of course. Everyone makes mistakes. But don't centralise control - in my experience that kills efficiency and motivation).

Accurate Architecture Models

By this I mean the kind of architecture topologies you create in tools like Enterprise Architect and others, where the boxes and lines aren't just boxes and lines - they have properties, and the modelling software understands the boxes as entities with behaviours and relationships with other entities.

While I applaud the aspiration to have an architecture repository, TOGAF style, experience has shown this to be a futile exercise.
Don't do it, for goodness' sake, especially if it's manually updated. You'll spend your life trying to keep it updated for very little value.

The main value of architecture diagrams is to communicate a concept. These tools, which strive for accuracy, impose limits on the kind of information you can convey, Typically you'll struggle to bring out the important features without showing the unimportant ones too. And with a restricted palette of visual indicators, you won't be able to bring out all the things that matter (high risk areas, data flow versus flow of control, areas that are changing in different phases, variations by environment, areas holding or transporting sensitive data, and so on).

And of course you'll probably diagram the same thing more than once for different stakeholders at different levels of abstraction - and no one likes looking at diagrams which are uniform and soulless. As humans we like things to be visually compelling, and tools like EA really, seriously, aren't.

In summary

Picture of an architect working *with* the implementation team
Avoid hand offs. Get the people you need
working together on each small thing, all the
way through. That includes architects!

The responsibility of an architect is to be the person who has thought of things from all angles, and from the broadest possible perspective; they should take the high level strategic view.

But that doesn't mean that they shouldn't involve themselves in the detail of the implementation. Architecture should come from the people who know the detail, and be ratified by them (as well as all other stakeholders). It's the architect who makes all this happen - collating, rationalising, and aligning - driving technical decision making. Ensuring that the design is as simple as possible, and as modular as possible.

Finally, the architect should be a member of the implementation team, collaborating on design just in time, rolling their sleeves up when necessary, and paying attention to the build, deployment, and operational support of the stuff they build.

It's common sense really - which, at the end of the day, is what Agile is really all about.

Further reading - a pragmatic and detailed guide to agile architecture - the 6 principles of continuous architecture from the blog by Pierre Pureur (co-author of Continuous Architecture).

Tuesday, 17 May 2016

The Shit Nightclub antipattern

You go to a fancy looking nightclub. It's on Leicester Square in London - it must be good. The thumping music carries with it on the evening air the magical lure and promise of good times, so you pay the £20 entry fee and the suited bouncers let you in.
Then you discover that there's no one in there. And as the minutes and hours slip by, the place doesn't really fill up - but it's sure to soon, right? One of you suggests going somewhere else, but you point out that you've all paid £20 to get in. We should stick it out a bit longer.

And this is what happens with large IT projects.

Now IT projects are hard. No two are the same due to the shifting quicksand of technology, and the particular perspectives of the myriad stakeholders involved.

IT projects are also time consuming. They usually take at least twice as long as anyone thought they would - mainly because of the first point; no one can hold all of it in their heads, or at least not in "working memory".

Lots of problems stem from these two things: Budgets get blown out of the water, businesses don't get to market quickly enough, a work-late culture develops, morale ebbs away...

But like any teacher will tell you, just because it looked great on your lesson plan, if it's not working abandon it!
And this is what businesses are often unable to do.

This is what happens:

  • Someone estimates the project as 3 months.
  • A team breaks down the work and adds up the estimates. It becomes 6 months. (If you break work down and add it up, the estimate will always grow).
  • Some things get de-scoped. Some estimates get squeezed. They arrive back at the 3 month estimate, and senior stakeholders are appeased.
  • Work begins, and in the early days it becomes clear that things are slipping. Badly. But the PM (yes we're probably talking about a non-Agile environment) sits on this information rather than put the cat among the pigeons - after all it's early days, we might be fine.
  • The three month deadline approaches, and the PM goes cap in hand to the stakeholders and makes a poorly thought through request for one more month.
  • Two months later the team is exhausted and miserable, and the backlog is still groaning with work (including the performance testing - everyone agrees we really should get going on that). 
  • The PM is secretly angry with the team - how can they have taken so long? Why is it always like this?
  • The stakeholders are angry with the team - they put money and reputation on this project, and these developers are obviously not up to the job. More developers are dragged (possibly literally) to join the team.
  • The developers are all talking about leaving (except the guy who isn't very good).
  • The system is now complex and buggy, and more worryingly, it's laughably far from the performance targets they set at the start. How can it take 20 seconds to return a page?
  • At 6 months, a senior architect or tech lead is parachuted in. The PM is changed. More and more money is sunk into the project. It can't fail now, otherwise everyone's wasted half a year and a scary amount of money. More importantly, the stakeholders will look like fools.
  • The project limps out the door at 9 months, performing poorly and riddled with bugs.
  • The business decides they need more rigid and formal processes to stop this happening again.

So if you find yourself in a shit nightclub, consider your options:
1. Stay. Then you'll end up having spent lots of money, and having had a shit night.
2. Leave. Then you'll end up having spent lots of money, and possibly having a good night.

Your choice.

Thursday, 15 October 2015

Nuance and momentum

In most companies there's an understandable reluctance to commit significant budget to new ideas unless they're very well proven, and - critically - enough people in senior positions think they're good ideas.

So in order to get sufficient momentum for an idea, it needs to be repeated and communicated many times - and thereby loses any nuance of meaning. It becomes necessary to distill the essence of it into an "executive summary" that, especially for technical ventures, often misses the point by a small but important margin.

In the company I currently work in, various technical people, including myself, have been pitching to refactor a particularly complex area of our architecture. It doesn't perform as well as it needs to, and is also the frequent source of insidious bugs in our live environment which are hard to debug since the system is hard to reason about. 
We have a proposal for how it could be designed differently, but in order for this proposal to gain momentum, the point of the work has been diluted through Chinese whispers to the basic premise of "Make it go faster". The enormous benefits in future technical enablement are glossed over. (Of course, in most companies, eliminating technical debt is considered a Good Thing, but when it come to the crunch, no one wants to invest in it. Where I work now is a hundred times better than most at this, but it's still short term wins that really get people going).

Why does this matter? The message that has become fixed on is the short term performance benefit which yields greater opportunity for sales. This benefit is much smaller than the more intangible longer term advantages, and so the idea hasn't made it very high on the agenda.
What's more, ideas with no short term benefit will probably gain no momentum at all.
And when (if?) the idea comes to be engineered, the senior business stakeholders may be impatient for it to be completed, as they don't understand the nuances of how much long term benefit they will be getting. In some companies, this can lead to the project being canned before it's complete (see Death By a Thousand Incomplete Refactorings), or made more difficult by technical teams being asked to work on short term things in parallel.

If only business people could invest more time in understanding technical matters. Of course, one barrier is that us techies are often resistant to that at a subconscious level - we take pleasure in our area of expertise being impenetrable in much the same way I suspected Polish people liked seeing me struggle with their pronunciation and grammar when I lived there. (Different endings for different numbers of things - seriously?)

But the other barrier is that we make our systems too complex. Perhaps a good rule of thumb should be: If non-technical people don't understand our systems, then they're too complex.

So, returning to the topic of gaining momentum and losing nuance, what's the answer? It seems to me it's the same answer I return to again and again in IT (and many other areas): 
Better to restructure your organisation to allow for small independent teams to make their own decisions and set their own direction. That way, less momentum needs to be built up and more nuanced communication can occur, using a rich shared vocabulary.

Is Eliminating Cross Team Handoffs Possible?


Well, not completely anyway. But just because you can't achieve something doesn't mean you shouldn't strive for it.

Lots of advice floating around in the Agile space tells you that handoffs from one team to another are expensive and inefficient: The DevOps movement has given way to the Anti-DevOps movement, suggesting that the development team should do their own Ops; I've written about The Vicious Cycle of Support whereby the development team should support their own output; separating business teams from technical teams can lead to an unpleasant client-supplier relationship where neither side can work effectively.
So do we just need one huge team with everyone in it?

Well, yes. Except for the "huge" bit.

It's been a core concept of most Agile doctrines that you keep your team small, and your immediate scope small. And the people in that team don't just stick to one role - they chip in and help out wherever it's needed.
I've said before that I think the optimum set up is two developers and a product person. That assumes, however, that all those people are very experienced, and are willing to cover off between them the jobs that we typically divide up into the separate roles of Business, UX, Design, Coding, Testing, Release, Support and so on. That may sound ambitious, but consider the benefits:

  • No communication overhead. Everyone knows exactly what's going on, and everyone is working from the same assumptions.
  • Focus. There's no way you're going to be able to juggle 5 projects at the same time like bigger teams are often expected to do.
  • A sense that you really are a team, and that you own this deliverable end to end. This is the same reason that startups are such exciting and dynamic places to work, and often take the market by storm. 
  • You wake up and feel motivated to come to work! It's fun. And when people have fun doing their jobs, all sorts of virtuous cycles develop. Talented people want to come and work for you. People feel inspired to come up with genuinely new and exciting ideas.
  • Everyone in that small group is forced to understand all the domains end to end, which were previously kept separate. And when people understand things end to end, your quality shoots up because there are no unexpected implications from decisions made in isolation; there are no lost opportunities ("if I'd known that was something we'd want to do, I'd have built it differently!")
  • The team can be autonomous. No more waiting. No more chopping and changing at the whim of far-removed senior management or marketing teams. With clear goals, and empowerment, it's pretty amazing what three people can achieve.

(In case you're wondering why handoffs are bad, see Pawel Brodzinski's blog post on it)

The Vicious Cycle of Support

Developers who don't have to support their code in Production unsurprisingly don't consider all the implications of their changes.
Logging, monitoring and alerting are afterthoughts. Questions like "What happens when the network fails?", or "What if we run out of disk space?" aren't at the forefront of people's minds.
The difficult test scenarios get ignored because "We should probably test those things, but the test environments are rubbish and besides, this is how we've always done it."

But the result isn't just that a particular feature going live drags some poor guy out of bed at 3am (the traditional time that hypothetical production issues take place). And it isn't just that the metrics on number of live incidents rises over time. It goes much deeper than that.

When Support teams are separate to Development teams, developers don't understand the domain of Support, and vice versa.

The problem with the former is that systems that weren't designed to be supported are hard to support. The cost of that support effort grows over time.

The problem with the latter is that if Support people make fixes, they do so without understanding the domain fully. This causes further instability and technical debt, and also creates a system which neither developers nor support people understand.
Of course, developers continue to build on these foundations, which compounds the problem still further.

Still, you shouldn't be downhearted as a developer in this kind of company. At least you don't have to support it!

Death By a Thousand Incomplete Refactorings

Start with a fairly new IT system. The lead developers built it with a Shining Vision of the perfect architecture, and that vision has been realised. The team has put most of the finishing touches on it, the initial waves of bugs have been exterminated. We're proud of it. We even spend some time refactoring a couple of bits we rushed.

The lead developers feel like heroes. They stick around for a couple of years basking in the glory of being the people who understand the system inside and out.
And then, gradually, the realisation dawns that there's some technical debt which needs addressing. Possibly it's been there all along, it's just that the system scaled or was extended in ways we didn't anticipate. Possibly it's caused by developers building stuff without understanding the Shining Vision. Possibly it's down to The Vicious Cycle of Support.

Whatever it is, the Make it Shiny Again project is born. One of the original veteran lead developers spends all day every day telling people about how the Shining Vision got lost, and now enough senior people have listened. Troops are mobilised.

The big refactoring goes well at first. Everyone is behind it. Update emails go out gleefully reporting the excellent progress. Demos happen. Meetings show high level progress and sing the praises of the Make it Shiny Again project. It will destroy disease in the third world. It will bring peace to the Middle East. It'll even increase our unit test coverage.

But, inevitably, as the project stretches on and the full scale of the task becomes apparent, people begin to lose energy. It looks like the timescales are moving out. Fewer and fewer people are extolling the virtues of it. Even the veteran lead developer has got distracted by a new even shinier way of doing things. The project joins the ranks of other tedious long term projects with no sense of urgency, gathering dust at the bottom of the project plans. (In some companies, "long term project" means years. In some it means weeks. Either way, energy attrition occurs).

Eventually something goes live. It may feel like a pyrrhic victory, but it delivers value. One part of the system has been refactored, and is running successfully alongside the old system. No one has the energy to celebrate.

Some conscientious members of the team ask when we'll move on to the next phase of refactoring. Tumble weeds drift across the office floor. Strangely, no one fancies descending back into that dark chapter of their lives.

The final solution, once all functionality had been refactored, meant the switching off of the old system:

However, what the Make It Shiny Again project actually achieved was this:

Now drill deeper and look at the code. Many many incomplete refactorings of different things have happened. Everyone touching the code has either not understood that particular area's Shining Vision, or has sought to impose their own.
Now look at it from 30,000 feet. Whole swathes of the architecture (and the organisation) have undergone incomplete refactorings.
If you squint a bit, the architecture is a fractal. It looks like spaghetti at any level.

No wonder it all feels like such a mess. The solution? 
Let me unveil my Shining Vision. We'll finish it this time, honestly we will.

Less bleak footnote
This can be avoided. Some technical debt is inevitable1, but Death By a Thousand Incomplete Refactorings is not:
- Don't bite off more than you can chew.
- Deliver in small increments. If it's going to fail, make sure it fails early.
- Celebrate each small success. 
- Swap people in and out - keep it fresh. Let everyone be involved.
- Recognise the risk of an incomplete refactoring!

1 See Martin Fowler's TechnicalDebtQuadrant

Thursday, 8 May 2014

Bend Over Backwards. Now Stay There.

High staff turnover is a bad thing. Pretty much everyone would agree on that - especially for a development team where knowledge of the system is essential.
In fact surely keeping staff happy - retaining the best talent - is a priority for all managers.

But when the pressure's on, IT managers will end up cascading the misery to their team for the simple reason that all managers are primarily judged on and therefore incentivised by meeting project deadlines.

Meeting deadlines means meeting budgets and delivering ROI. In other words, it means making money - and this is the only priority of any company anywhere regardless of what their website says about CSR, diversity or people development. Money is all they care about - make no mistake.

So what does this mean for you as a developer? It means that the only person you can rely on to look out for you is yourself. If you regularly bend over backwards to meet deadlines then that becomes the norm. If you join the Working Late Gang, you give them strength in numbers - it becomes the culture. The unrealistic expectations, the flawed process, the poor planning - all of it is hidden or condoned by you picking up the strain and making it happen.