As developers, our main task is to make the journey from A to B. A is you and the idea of an application, and B is the actual application, working well, a happy client and job (or flow of work) security for you.
As with any other journey, how you make it very much depends on where A and B actually are, and how they’re connected into transport options.
Where I live there are three viable transport options: a 4-wheel-drive SUV, a tractor and a horse. When I lived in London I walked, bused and used the tube. A tractor or horse would have been pretty hard to park.
If I was going further afield, walking, bussing and tubing weren’t enough. I added trains, planes and boats to make my way around Hong Kong, San Francisco. I once worked on film in Norway where we used a helicopter to travel between two locations that were only 100m apart on the map. There was a raging unbridged river and a 1000m altitude difference between them.
When I develop an application, my choice of frameworks and utilities, and how I use them, is my mode of transport. I need to consider
- the distance between A and B
- the proximity of A and B to existing transport options
- how many people need to travel together
- the reality of the terrain
To be clear – this metaphor is about how you get to the destination, it’s not about how individual classes communicate with each other. The choices you make will then dictate the code. You, your team’s collective energy, is the precious part.
Prioritise your process over your product. Without your work, there is no code.
The reality of the terrain
The original London Underground Map is iconic – but it’s also a lie. This alternative version actually shows the distances between the stations:
This geographically accurate map still doesn’t tell you that it’s virtually impossible to cross the road between Euston and Kings Cross, or that changing between some lines requires a major hike and 3 long escalators, while switching between others is a 20 second hop across the platform.
But, it’s a better guide for choosing whether to walk or get the tube than the schematic that shows most stations as equidistant.
The more accurately you can assess your terrain, the more likely that your journey will go smoothly.
How many people need to travel together?
My least favourite part of daily commuting in London was the tendency, in the summer holidays, to step off an escalator and straight into the back of a stationary group of foreign students, identifiable by their matching backpacks or jackets.
If you want to keep a group of developers together, there are better ways to do it than to use a transport option suited to individuals and then have to congregate regularly to ensure that you’re all going in the same direction. Hire a minibus.
The proximity of A and B to existing transport options
I once lived right next to a bus stop. I could actually see the bus coming from my apartment, and make it to the bus stop just at the right moment. As you can imagine, I used the bus a lot. Most other people thought the bus was a crappy option – I guess they lived a long way from a bus stop on a useful route.
The robotlegs MVCS trousers use the eventDispatcher as a shared communication channel not just because events provide great decoupling if used in this way, but because the cognitive distance between any AS3 class and an EventDispatcher is negligible.
They’re also programmatically near to almost any class. If you’re plugging in a utility, or using a service, or working with some existing views, the chances are that they are ‘near’ to a way to attach to the shared eventDispatcher. You might wrap them in a proxy or mediator to take the final step, but you don’t have to take three extra modes of transport just to get started on the journey.
The distance between A and B
You do not need a framework for a 2 hour project. You probably don’t even ‘need’ object oriented code. Write a functional-style script. Do not charter an airplane to go to the store.
At the other extreme, cycling your way around the world is possible but damn hard work. If your client is paying you to get from A to B, they will rarely pay for you to do it by bicycle.
Mixed transport approaches
There is no single pattern, or approach, that can take you the entire journey if you’re going more than a short distance. You’ll need to combine transport options. Mindfully. The connections between these modes are where you lose or gain energy and time. Sometimes it matters that the choices are consistent, other times it’s irrelevant.
Identifying where it matters and where it doesn’t is hard. One of the things I like about the robotlegs mvcs trousers is that, applied cleanly and out-of-the-box, the framework makes it hard to get lost. It also makes it easy to carry a large number of people on the same project – as long as your ‘parts’ fire and respond to the correct events, we’re golden.
Again – I’m not talking about the code here, I’m talking about what you do, how you work with it, how irritated you feel when the client wants to add or change something, how much cognitive load you carry when you work on a class, how much technical debt you amass to keep you awake at night.
How do you feel about directions?
I shan’t resort to poor stereotypes about men preferring to drive round in circles here – my (female) partner can’t stand being given directions. She just wants to know where she needs to be, and she’ll work it out herself from there. She actually gets angry if you start to tell her which way to go.
I do like to get directions. If someone has travelled my journey a lot, and they’ve learned to avoid a particular street because at least half the time it’s snarled up with traffic, I am grateful for that advice. If RyanAir are cheap but never, ever get you there on time, I want to know that too.
My assumption is that because best practices have been developed through experience, if they were sucky processes they wouldn’t have been tolerated long enough to become a best practice. Over the years, coders have travelled journeys similar to my own project’s A-to-B, so when they say “take this path” they’re not just telling me that it’s the right direction, but also that the route isn’t boggy and doesn’t involve rock climbing – so I can walk if I like.
When we debate approaches we often confuse the code with the process.
So – I’ve well and truly worn out this metaphor. Just one parting thought: Don’t fall asleep on the train. Waking up in Cockfosters with a hangover at 1.30 am is no fun.