Skip to content

Instantly share code, notes, and snippets.

@leakypixel
Last active August 29, 2015 14:22
Show Gist options
  • Save leakypixel/5fc4d45e2d5c2472cfe1 to your computer and use it in GitHub Desktop.
Save leakypixel/5fc4d45e2d5c2472cfe1 to your computer and use it in GitHub Desktop.
Responsive Fairy Cakes

Responsive Fairy Cakes

James has a really good recipe for fairy cakes that he's going to take to a party, but he knows that people's tastes and dietary requirements are different, so he compiles a list of the considerations:

  • Angie doesn't want aspartame, because she's read some pseudo-scientific bullshit that tells her it's poisonous.
  • Jack is diabetic, so can't have sugar.
  • Harry really doesn't like coconut.
  • Lisa doesn't like real strawberries, but does like strawberry-flavoured things.

James' budget only goes so far, so there's that to consider, and his original recipe has the following ingredients:

  • Sugar
  • Flour
  • Eggs
  • Coconut
  • Strawberries for the topping

Taking into account his considerations, he makes the following adjustments:

  • Sucralose for the sweetener, so that both Jack and Angie can eat the cakes
  • Swap out the coconut for glycerine to keep the moistness, and a dash of vanilla for the taste

He wants to swap out the strawberries for strawberry-flavoured icing for Lisa, but since he gets his strawberries for free, his budget can't stretch to buying the strawberry-flavoured icing for everyone. He speaks with Lisa, and they decide that Lisa will take the 32p hit for the strawberry-flavoured icing, so that she can still enjoy a cake.

After all these solutions are taken into account, James has a recipe that works for everyone, with Lisa's special requirement being handled specifically for her. He makes five cakes, let's Lisa pick off the strawberries from her cake and have the icing instead. Everyone is happy and the cakes go down well.

This analogy can be used to explain the responsive philosophy - making something that works for every device as much as possible, and only making changes specific to a given device if it would negatively impact the others, and making sure that only that device has to deal with the overhead. When done in this way, we end up with a lightweight (fast to load and render!) page that everyone can enjoy regardless of their specific requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment