Process and Framework
You're about to jump into learning! So, where do you begin? Use this process at the beginning of each learning activity:
Process
- Get intentional and habitual
- Start your timer
- Understand: Get clear on what is being asked
- Plan: Plan your approach
- Divide: Break into small steps
- Attempt to solve it (write an initial solution)
- Get unstuck
- Improve your solution (Refactor)
- Learn what you learned (Reflect)
- Practice
Why?
Credit: Adapted from Richard Reis
Problem-solving is a meta-skill. And thinking like a programmer requires you to problem solve. Without a process and framework, this is likely a way you'll go about 'solving' problems:
Get a cup of tea. Try a solution. If that doesn't work, try another one. Respond to message on Facebook. Try solution again. If that doesn't work, repeat until you luck out.
Sometimes you'll luck out, but the best way involves a) having a framework and b) practising it.
Framework
"The biggest mistake I see new programmers make is focusing on learning syntax instead of learning how to solve problems." — V. Anton Spraul
So, what should you do when you encounter a new challenge?
0) Be intentional and build a habit
Be intentional about developing habits that will grow you as a learner and a programmer. During the Prep Curriculum you will have spent sometime exploring this domain. If you haven't done this yet, we recommend doing so now.
At the beginning of each day:
- Ask yourself 'The Two Questions' and write them down:
- What are my goals today?, E.g. "Complete JavaScript blog challenge" or "Spend 4 hours coding."
- What are my challenges today?, E.g. "To keep to the timebox suggestions" or "To back myself and celebrate my progress."
- Commit to Focus:
- Assess your focus
- Eliminate distractions
- Practise attention training (mindfulness, even if just for 2 minutes - you'll learn more about this as you progress through the course)
- Focus on one thing at a time
- Live in the moment
- Apply the principle of "just in time" learning (don't try to learn it all)
- Plan to take short breaks
1) Understand
Know precisely what is being asked. Most complex problems are challenging because you don't understand them (hence why this is the first step).
" "How do you know when you understand a problem? When you can explain it in plain English. If you can't explain something in simple terms, you don't understand it." Richard Feynman
Write down the problem in plain English, doodle a diagram, tell someone (or something) about it. Some people use the Rubber Ducky Method.
2) Plan
Don't dive right into solving the problem without a plan (and somehow hope you can muddle your way through). Plan your solution!
In programming, this means don't start hacking straight away. Give your brain time to analyse the problem and process the information.
To get a good plan, answer this question: "Given input X, what are the steps necessary to return output Y?"
Write out the steps in plain English, either on a piece of paper or as pseudocode (comments in your code).
3) Divide
The most important step of all! Do not try to solve one big problem!
"If I could teach every beginning programmer one problem-solving skill, it would be the Reduce the Problem technique.
For example, suppose you're a new programmer, and you're asked to write a programme that reads ten numbers and figures out which number is the third highest. That can be a tough assignment for a brand-new programmer, even though it only requires basic programming syntax.
If you're stuck, you should reduce the problem to something simpler. Instead of the third-highest number, what about finding the highest overall? Still too tough? What about finding the largest of just three numbers? Or the larger of two? Reduce the problem to the point where you know how to solve it and write the solution. Then expand the problem slightly, rewrite the solution to match, and keep going until you are back where you started." — V. Anton Spraul
Break your big problem into sub-problems. These sub-problems are much easier to solve.
Then, solve each sub-problem one by one. Begin with the simplest. Simplest means you know the answer (or are closest to that answer). Now connect the dots - connecting all your sub-solutions will give you the solution to the original problem. Congratulations!
4) Attempt to solve it
Piece it together and start cracking the code.
5) Stuck?
First off, take a deep breath.
A key indicator of a programmer's mindset is how they respond to bugs and errors. Tune in: are you feeling curious or irritated? Remember that errors and bugs are conducive to your development (and that programming is full of them!) Adopt a 'not yet' attitude and go in with curiosity.
Here are some things to try when facing a whammy:
Debug: Go step by step through your solution to find where you went wrong. Programmers call this debugging. Try outputting a result at different points in your solution to determine where the code stops meeting your expectations.
Reassess: Take a step back. Look at the problem from another perspective. Is there anything that can be abstracted to a more general approach?
Research: Ahh, good ol' Google. You read that right. No matter what problem you have, someone has probably solved it. Find that person/solution. Do this even if you solved the problem! (You can learn a lot from other people's solutions)
Ask: You have many other learners on this journey alongside you who might be able to explain a concept in a way that lands for you. Your facilitators are also great people to ask - they are trained to prompt you with guiding questions to help you fine-tune your process rather than provide solutions.
Caveat: Don't look for a solution to the big problem. Only look for solutions to sub-problems. Why? Because unless you struggle (even a little bit - i.e. with piecing those sub-solutions together), you won't learn anything. If you don't learn anything, it is a waste of your time.
6) Refactor
Refactoring is not about solving the problem differently; it's about solving it well.
Good solutions don't just work. They are clear and - where possible - concise.
For more info see our Refactoring Resource.
7) Reflect
There is an increasing amount of evidence that reflection is the most important aspect of learning within the learning domain. However you learn best, you'll reap the most rewards by spending time reflecting on your experiences.
Ask yourself The Two (end of the day) Questions
Have I reached my goals for today? If yes, take a moment to enjoy that you reached it and ask yourself what you've done well today to reach your goals. If not, ask yourself what you can do better the next day to make sure you reach your goals. If you fail to reach your daily goals day by day, try different ways of working to improve them. Don't give up. If you reach your daily goals day by day, try giving yourself more ambitious goals and see what happens.
What have I learned today? Take a moment every day to ask yourself what you've learned today.
8) Practice
Don't expect to be great after just one sprint. If you want to be a good problem-solver, solve many problems!
Practice. Practice. Practice. It'll only be a matter of time before you recognise that "this problem could easily be solved with insert concept here."
Conclusion
Problem-solving is an incredible skill to cultivate (the meta-skill). When engaging with learning, use the process and framework and weave it into your habit.