PROBLEM SOLVING TECHNIQUES
Approaches to Problem Solving
In this post I will discuss the use of certain techniques to overcome blocks when solving problems
Blocked on a Simple Problem:
While attempting to solve one of the kata challenges, I became blocked on a problem, which was simple as it was syntax related however because of this my code was returning an error.
I was trying to pass the final deBee test using the .toUpperCase()
method.
I was using the built-in method filter
and was passing the test to remove 'buzz' words.
The filter()
method creates a new array with all elements that pass the test executed by the function provided.
Test - Pass
//deBee should return a string where the word buzz has been removed
const filterBuzz = words.filter(word => word != "buzz");
To pass the first test did involve understanding the use of the filter
method, however when I ran the test again with the .toUpperCase
method I could not figure out why it was working.
The .toUpperCase
method converts a string to uppercase letters, without changing the original string
In this challenge it was required to change the string 'buzz' to uppercase in order to pass the final test:
Test - Fail
//deBee should return a string where the word buzz has been removed, regardless of capitalization.
const filterBuzz = words.filter(word => word.toUpperCase != "BUZZ");
This failed test was due to syntax - forgetting the ( ) on the method .toUpperCase
the error message here was not helpful so I had to Google the method, and then tried it out in my code editor and found the problem
I already knew syntax was important, however from this I did learn to be more careful when writing the functions to ensure syntax is correct, as a simple problem like this can still be a large blocker - especially when you are new to programming.
Elegant Problem Solving
My most elegant attempt (still finding my feet with JS) at solving a problem was during the JS Gradebook challenge, this is where I combined a few different problem solving techniques including:
- Pseudocode
- Googling
- Trying something
- Reading error messages
During this exercise I felt that, because of these techniques my problem solving flow had vastly improved (not hard). I also began to feel more confident using Javascript during this challenge.
Problem Solving Techniques
- Pseudocode
(med) - I have only just discovered pseudocode, and definitely rely on it in order to solve problems – if I don’t use it, it feels like I am trying to open a window which is glued shut. - Trying something (high) – When approaching problems, I don’t like to feel as if I am getting nowhere, so I will try different things until I understand where I am going wrong, or better yet – solve the problem!
- Rubber ducky method (med) – I am usually studying in a public space, so I cannot exactly start talking to an inanimate object.. or can I? I have not used this method much, but know it does yield results.
- Reading error messages (med) – I find error messages useful, especially for syntax errors, not so much for more complex problems.
- Console.logging (med) – This helps a lot with debugging and understanding code, and I am reasonably confident with the use of console.log()
- Googling (high) – Googling is great, when I know what it is I am looking for! And additionally it helps to go over methods/functions etc. and check syntax. Big fan of Google, I cannot imagine what it would have been like to be a programmer in the 90’s.
- Asking your peers/coaches for help (med) – This is an approach I have seldom utilised, however I think my confidence with this will increase during Bootcamp, as I am starting to find the challenges more difficult.
- Improving your process with reflection (high) – I really do find reflecting on challenges, and learning, to be a useful practice. It can help solidify the information gained, and highlight any gaps in knowledge – I use this one a lot.