Sometimes we just want to dive into our code, head first. My University teachers always told us that we should plan our code before starting, but that’s a lesson that only sunk in after wasting more time due to lack of planning.
One day I came across with the OODA loop. The USA military uses it to make better decisions and think more critically. I found it can also help me make better decisions while coding, so I’m sharing it here because it might be helpful for you too.
- Observe - Analyze the problem you are trying to solve by using code.
- Orient - Make sense of the information and think about a possible solution. Write down the initial pseudocode to help you understand how you will proceed.
- Decide - Decide what tools you’ll need to achieve the solution. For example, do you need any particular data structure? Which algorithm is a better fit?
- Act - After planning the solution, it’s time to implement your decisions by writing the code.
Remember, this is a loop. So if you ever get stuck, just keep iterating.
How do you plan your code? Do you follow any framework?