Mise en place for coding
Chefs employ mise en place (“everything in place”) as an initial step before beginning to cook a meal. It involves gathering all the ingredients, measuring out or weighing each to the quantity required, and then laying everything out along with any pots/pans, or other tools required for the recipe. This serves a couple different purposes. It makes certain that you have everything you need so you don’t get halfway through a recipe and say, realize you’re out of butter or need to hunt down a pan that is dirty. It also makes the actual cooking process much more organized and therefore smooth and enjoyable. I’m no professional chef, but whenever I take the time to implement mise en place at home before starting to cook, I find it to be a much more relaxing process.
This technique is not just useful for chefs, I’ve found that it is powerful when applied to coding as well. I used to have this bad habit of diving into a problem head first and trying to code my way out of it. Sometimes it worked, but I more often would end up needing to take a step back and come up with a better, more thought out solution. As my coding skills improved, I have learned that when solving a new problem, I first need to do some setup before writing a single line of code. I needed a mise en place process.
Here is my mise en place for coding:
Brainstorm possible solutions to the problem (roping in someone else to help if it’s a particularly tricky issue)
Go to the whiteboard (or grab some paper) and jot down any algorithms required either as steps or in a flow chart diagram
Make an outline of all classes including possible names, instance variables, and methods with arguments
Review documentation for any classes/methods/frameworks I will need to use that are not familiar
Write unit tests - determine how I want the new code to be used and the edge cases, beforehand
Once I have completed my mise en place, I feel much more confident in the approach I am taking to a solution and it is much more likely to be successful. The goal is not to completely eliminate refactoring. Refactoring is needed to polish up code or just because you learn things during the implementation process that may change your algorithms a bit. The goal is simply to start off on the right foot, with a well thought out solution. Overall, the mise en place process is significantly improving my code.
Bonne Programmation!