By Harry Roberts CHAPTER 1
Another analogy that I have used before is the Subway analogy. If you
have ever ordered at a Subway sandwich store you will be familiar with the
way they offer food. They break everything into separate ingredients, so
you can combine your chosen meat with your favourite salad and top it all
with your favourite sauce.
Breaking things down to this level affords an enormous number of
combinations of the same basic ingredients, and it allows customers to pick
and choose the bits they do and don’t want. One day you could have tuna
and cucumber with sweetcorn and mayo; the next day you could have cured
meats with mayo, onion, lettuce and cucumber. There are some ingredi-
ents shared across both, but because each is distinct, you can simply swap
ingredients and make entirely new sandwiches. So, instead of coding up a
sandwich, code up all the ingredients and make your sandwich from those.
By thinking of your code in the same way as you do Lego and sandwich
ingredients, you should be able to start looking at the smaller pictures and
focus on easier, micro-tasks. The result of these tasks is a whole load of
combinable chunks of code.
wheRe To bReaK iT uP
It’s all well and good saying we need to break code down into smaller piec-
es, but where do we break it all down?
Unfortunately, there is no right or wrong answer. But! I do feel there are
some helpful analogies and pointers. I mentioned earlier that breaking things
down is just common sense, so think now about how you, as a Web develop-
er who’s probably never worked in construction, would go about building a
house. I imagine we’d all build a house in roughly the following order:
- Foundations upon which to build everything else.
- Structure such as walls, to keep the building up.
- Fixtures like doors, windows and staircases.
- Decoration like wallpaper or paint, carpets or wood flooring.
- Ornaments such as paintings, canvases and posters.