Problem-solving strategies to solve Einstein’s Riddle
August 16, 2017
 

Can problem solving skills be improved with practice?

 

Monday, August 14th, 2017

Problem solving is a skill that can be improved through focused practice.

Just like mastering the piano, playing baseball, or nailing a complicated dance routine, it just takes focused practice.

At a high level, what do developers mean when they say that ‘you need to be a good problem solver?’

When developers say that you need to be a good problem solver, at a high level, can you to turn words into working software. For example someone might say they want to build “Uber for Power Tools” – just 4 simple words might take months or years to solve, and will involve thousands and thousands of smaller problems.

George Polya’s method for solving problems

  1. Understand the problem
    1. Identify inputs and outputs
    2. Ask “What if?” questions to discover edge cases
  2. Devise a solution
    1. Come up with more than one potential solution
    2. Choose a solution based on:
      • Performance (time and space complexity)
      • Maintainability
      • Your ability to code it
  3. Carry out the solution
    1. Dispense with boilerplate code
    2. Code “outside in”
  4. Look back
    1. Ensure correctness
    2. Look for opportunities to refactor
      • Check for DRY – Don’t Repeat Yourself
      • Check for SOLID – Single Responsibility, Open/Closed,
        Liskov Substitution, Interface Segration, Dependency Inversion

The article mentions that problem solving is ‘cyclical and fractal’. What does that mean?

Learning these problem solving techniques is both cyclical and fractal. That means we use them a lot. When we start a project, we might run through the 4 steps over the course of weeks or months. Then when we are focusing on any individual feature of the app, we may run through the steps in hours or days. And when writing a single unit test we may run through the steps in a matter of minutes.

What is a “productive developer”?

We can define “productive developer” as one who frequently solves a problem a user has, and gets that code out into a production application with a steady velocity. Half but not half-assed. In other words, a productive developer is one who consistently and predictably ships working software.

What are some common software patterns?

Code

  • Accumulator pattern
  • Recursive iteration (first/rest)
  • Recursing over a tree
  • OOP
  • Dependency Injection

Apps

  • Routing
  • Validation
  • Associations
  • Model-View-Controller
  • Input-Transform-Output Pattern
  • Authentication and Authorization
  • REST
  • CRUD
  • Persistence

Good Developer Workflow

Part of being a productive developer is just being fast at things. This can come from the simple, obvious things like typing fluently, but also comes from:

  • Understanding how to debug code quickly (stack traces, debuggers etc…)
  • Write code “outside in” so you can follow error messages
  • Use Git effectively so you can take risks and experiment without losing work
  • Writing automated tests so you can run through the Polyá steps efficiently
  • Being a power user of your machine (understanding package management, command line tools etc…)

In conclusion, there is no one way to a solution. First identify inputs and outputs, then ask “What if” questions to discover edge cases, and finally devise a solution as lean as possible!