Monday, July 11, 2011

Apprenticeship Patterns: Patterns and Anti-Patterns of Problem-Solving

The Intellectual Side of Problem-Solving:

(Borrowing heavily from AI terminology)
Imagine a 3D Cube containing the start-state, the goal-state, the problem-space and the solution-paths.
You're essentially scanning a problem space for a solution i.e. a combination of sub-steps which finally lead to goal.
1) Explore the problem space first i.e. try out things
2) Identify what worked or is promising and extend the branches into the sub-problem spaces
3) Recurse over the sub-branches until you've covered enough of the problem-space.
4) If the volume of the problem-space is vast it may help to BackTrack from Goal towards the problem state.

This reduces the volume of problem-space to be probed for possible solution-paths. This is known an "Alph-Beta" Pruning of the (Decision??) Tree.
//TODO: Add Diagram of 3D Problem Space and Decision(??) Tree.


In Nature, Lightning follows a very similar method of Back-Tracking.
It seeks out the easiest path between cloud and ground through an insulating volume of air.
Actually there is an initial weak backtracking path from ground to cloud, followed later by a strong return path.
//TODO: Add picture of Lightning fingers

The Emotional Side of Problem-Solving:

Basicially we must first ask "Why" is problem-solving so important?
Not all problems we face are life-threatening to require immediate attention.
So then what is it that makes solving them so important in the first place.

Refer:
1) Psychology of Computer Programming by Gerald Weinberg
2) Emotional Intelligence

Experience - coming to terms with "immediate failures" vs. "future pay-offs"

1) Try out many things to get a better solution or a solution which appeals to your way of doing things.
2) All the things you try won't/can't succeed at least immediately.
   Mostly many of these "dead-end branches" are just waiting for the right time to flower. You're actually building up a fund of ideas and efforts which will help you overcome some other obstacle.
   Example:
   Unix was a result of dissatisfaction with implementing Multics which itself was a replacement for some other O.S.
   Ken Thompson went on to implement ideas for distributed O.S in CODA, Plan9 etc. 30-40 years later these lessons learned and 'the-roads-tried-but-not-taken' have resulted in writing a 'go' language.
   It's used in Google which puts those same ideas refined over time into concrete working programs.

3) Watching my son getting frustrated when his cycle got stuck in a corner.
   He'd start screaming and banging the cycle into the wall.
   Beating it with red-face and small fists.
   The tears of frustration and incomprehension as to why the universe conspired against his cycling.

4) This felt so much like my own frustration with my own efforts.
   The perceived low return-on-investment of the "meagre" results.
   So many ideas half-implemented, unimplemented and ALL the wonderful things not even attempted i.e. 'the-road-not-taken'.
   The universe almost conspiring to thwart each hope and attempt at magically succeeding at all things.

5) Frustrations comes from other people's expectations.
   And more so our own awareness of not "measuring-up" to their and our own expectations.
   Perfectionism adds heavily to an already sticky situation.
   A feeling that time is running out.
   The impending joining of ranks with washed-out oldies.
   A feeling of helplessness and hopelessness that things can't/won't change no matter what.  
   Unable to leave coding and unwilling to change to management (manipulating people not machines).
   Fear of becoming obsolete, of not living up-to the dreams, hopes and self-expectation built up over the years.

----

Patterns: The Middle Path between the Emotional and Intellectual Sides of Problem-Solving

"Why patterns work?!!" AKA "All I needed to know about Patterns I learned in Kindergarten"

Patterns force you to Think and NOT concentrate so much on the Feeling part (which is the cause of frustration)
a) Read, understand, see how the Pattern fits the Problem.
b) Re-evaluate the problem itself.
c) Try carrying out/coding the Pattern.
d) Customizing the Pattern to the situation.
e) Utilize your Feeling side by reflecting on aesthetics as pattern application is a very qualitative activity.

Patterns are primarily a set of ready-made formulas (cookbook-style) for successful problem-solving.

Raise Flagging Hopes:

These are also sufficiently magic-endowed by hearing good things from others etc. This helps you get over the inertia of hopelessness or feeling stuck at a problem. "Who knows this just might work - I've nothing to lose."

Abstract the problem solving process.

De-personalise the problem takes the bite out of it.
If the trial fails it's just the Pattern failing NOT you.
You're fore-warned to try out different patterns for different circumstances.
So you just try some other Pattern or just do something else.
Since the Pattern comes from outside, you give yourself time to understand it.
This is the crucial part where you become accepting of time and effort to customize the Pattern to your particular situation.

Conclusion:
Patterns are very effective Devices for Distraction from Result and Focus onto Process instead.

  1. Failure Modes of Hacker Schoolers : https://www.hackerschool.com/blog/66-four-failure-modes-of-hacker-schoolers