Solving Problems Like a Pinball

When solving a problem, imagine you build a pinball. The ball must reach the back of the play field when you hit it with the flippers. So the first thing to do is remove all the obstacles and make sure it reaches the back. Only then you can add the obstacles one by one while ensuring it keeps working every time.

That’s what my teacher used to say during programming classes. When starting a new project, or a new feature, start with the most basic thing, then iterate in small increments.

Need to add a label in a view? Place it at the center with a bright color so you can’t miss it. Then you can move it to its final position.

Need to connect to an API? Hard-code the URL and credentials and make the connection succeeds. Then you can create a view that asks for credentials.

Need to create a custom transition between views? Create a new ‘lab’ project dedicated to this task. Once it works you can move the necessary code to your big project.

Go the easy and lazy way first, then improve. Hard-code values, use bright colors, or even start a brand new little project and make sure that what you have to do works at its core. Once it works, you can add obstacles one by one.

It’s something we all know but sometimes forget. I found the comparison with the pinball quite funny so it stuck in my head.