After tackling my first coding kata, I have felt frustrated and blocked multiple times.
Although I’m not yet at a stage of elegantly solving problems, I do feel more confident and in control if I’m following a problem-solving process.
Below is the step-by-step problem solving process I’m trying to follow.
My problem-solving process
Look at your kata problem. What is the input and what is the output required?
Draw a diagram (on paper or a whiteboard app) of the input and output. Below this, try to think of the steps that would be needed to get from input to output. E.g. Steps 1-5 or however many steps might be needed. Write these in plain english. E.g. Step 1: Separate fullName into firstName and lastName. This is called pseudocode.
Start with Step 1. Try to think of what variables and methods you would need to achieve this. Google something like “js separate sentence” and read about the methods on MDN or W3 Schools.
In your replit or sandbox, attempt to write your first step.
Underneath it, use console.log() to check that the new variable looks how you imagined it, and test.
If Step 1 looks good, move on to the next line for Step 2. Repeat thinking / research / console.log until it works.
If you get stuck… take a break, talk it over with your rubber ducky, google more, ask a friend or coach for help etc.
If stuck for over 10mins, take a look at the answer. This is ok as it is a form of learning.
Looking at the answer, break it down into steps and see if your steps were similar, and where you got stuck. Research any methods you didn’t know.
Once you have an answer that works, take a break, then delete it and try to write it again. Even try again in a few days, to make sure the knowledge is secure in your long-term memory. Reflect on how the process felt the second time around.
This was inspired by Aaron Jack’s youtube tutorial on the subject - see below.
How have these problem-solving methods worked for me? Some examples:
‘Using console.log’: I have found it coming more naturally to use this as often as possible. Each time I define a new variable, I check it with console.log. I also check any variables given initially to uncover more about the problem.
‘Taking a break’: I’ve started using Pomofocus again and taking both the short (5mins) and long (15mins) breaks. I also tried taking a 20-minute nap which seemed to help on returning to the problem, although it is not always practical.
‘Return and rewrite’: I felt encouraged, upon going back over some Sprint 4 kata, that they did seem less daunting. It was confidence-building to be able to do these with less assistance than the first time around.
'Trust the process': I have printed the process above, to keep on my wall and in my notebook. Having a plan to follow helps when I feel overwhelmed.