Rongohua o te Korimako

Technical Blog—Problem Solving

Problem solving is hunting. It is savage pleasure and we are born to it. Thomas Harris (1940–) American Author

Experiences

  • Tell your non-tech friend a story about a time you:
    1. Got blocked on a simple problem
    2. Solved a problem in an elegant way
    In both cases:
    • What was the problem?
    • What problem solving techniques did you use?
    • How did you feel throughout the process?
    • What did you learn?
  • The following situation frequently occurs when teaching web design to secondary school students. As their teacher, I am also the chief problem solver when they get blocked.
  • Problem: “My picture’s not working!”
    Techniques: Trying something followed by improving the process with reflection (both the teacher's and the learner's processes). There are a number of things to check:
    1. Is the <img> tag written correctly?
    2. Is the picture saved in the images folder?
    3. Does the filename have the correct suffix in the <img> tag? (Usually .jpg or .png)
    4. Is it a valid picture file? It is not unknown for students to save .jpg files as .png or vice versa.
    5. Has the student appended .jpg to the filename? In this case, the picture is actually filename.jpg.jpg!
    6. One of the most difficult things to troubleshoot is where the student has inadvertently put a space on the end of their filename. [images/filename .png] but their image tag says, <img src="images/filename.png">
    Feelings: These are mistakes that beginners make and the solutions also involve teaching problem solving. At times it can be frustrating, but the teacher has to exhibit patience. Also it is important to complete the process by asking, “What have you learned from this?”
    What did I learn? For commonly occurring problems, it is important to have a repertoire or checklist of things to try. This is honed by reflection. Also, in this case, there is usually a viable solution.
  • Problem: “My picture’s not working!”
    Elegant technique: Let the browser tell you. Drag the picture file into an empty browser window.
    • Does the picture appear? If not, the file has been corrupted or is not a picture file.
    • Look at the address bar for the filename. Is it the correct images folder? Does the filename contain any %20 (space) characters? What suffix is the browser showing?
    Feelings: This technique generally pinpoints the problem fastest. Solving the problem quickly brings a sense of accomplishment.
    What did I learn? Problems that are resolved quickly are usually not regarded as big ones. Plus, this is a useful strategy for students to try problem solving on their own.

Techniques

  • Reflect on how confident you feel using the problem solving techniques and process:
    I feel confident using most of these problem solving techniques.
    • Trying something
      Perhaps this should be called ‘Trial and Error’. I avoid trying things until something works and leaving it there. It is important to understand why the problem occurred and to reflect on how it might be avoided or minimised in the future.
    • Rubber ducky method
      This is probably the last technique I would try: explaining the problem to an inanimate object. I would feel very self-conscious, particularly if I was in a workspace with others. That said, I have used the variant technique of explaining the problem to someone else and having the solution emerge from my description, before the other person had any input.
    • Pseudocode
      Writing an algorithm in structured English can be quite useful, particularly if the program logic is complex.
    • Reading error messages
      Error messages are an essential part of problem solving when programming. Firstly, they identify that something is going wrong and they can sometimes pinpoint the problem.
    • Console.logging
      After trying something, this is usually my second choice. When it is apparent that something has gone wrong, adding debugging statements to the code, or stepping through the program are usually very effective.
    • Googling
      It's rare to discover a problem that no one else has ever encountered. Sites like Stack Overflow are invaluable for finding discussions of problems and how others have resolved them.
    • Asking your peers for help
      Often it is a case of whether peers have sufficient expertise to help, or whether they are available to help in a timely fashion. Sometimes, this technique can turn into ‘rubber ducky’ with a real person. However, if there is a suitable forum: email or a discussion group, calling out to peers can be useful.
    • Asking coaches for help
      I feel comfortable using this strategy, provided that coaches are willing and available in a timely way.
    • Improving your process with reflection
      I think this needs to be part of all of the above techniques. It is only by reflecting that we learn and can do better in the future.

JavaScript Array Methods

  • Explain to your non-tech friend what these functions do in your own words:
    The following functions are all array iterators or methods that operate on a list of values.
    • .map()
      The map() method creates a new array (list) with the results of applying a function to every element in an existing array.
      let numbers = [1, 2, 3, 4, 5]
      let doubleNumbers = numbers.map(function(number) {
      return number * 2
      })
      console.log(doubleNumbers) // [ 2, 4, 6, 8, 10 ]
    • .filter()
      The filter() method checks every element in an array to see if it meets certain criteria and returns a new array with the elements that do so.
      let fruit = ['apple', 'apricot', 'banana', 'blueberry', 'cherry']
      let bFruit = fruit.filter(function(fruit) {
      return fruit[0] === 'b'
      })
      console.log(bFruit) // [ 'banana', 'blueberry' ]
    • .reduce()
      The reduce() method reduces an array to a single value. It can:
      • Reduce an array of numeric values to their sum;
      • Reduce an array of arrays to a single array;
      • Reduce one of an object’s properties to an array.