Problem Solving Stack

I recently started a new supplementary coding technique that I have not heard about anywhere else. I’m not sure what to call it, although internally I’ve been calling it streaming, an abbreviation for stream of consciousness programming. It works by writing out how you are solving a problem.

Here’s a real-life example that likely took place over the course of a couple of hours:

control_parsing
 Go through documents and figure out what appropriate values would be for the metadata and the control data to get it out
  Given a standard document, the ability to correctly parse out the fields
   Given a patient identifier, find the matching patient
    What API call do I use for this?
     Where is the system id of 387 coming from?  I could swear I've seen that before
      I don't think it's actually used, I think that we just use the patient identifier and the user's institution id
       Pretend we are calling the API call with the known patient identifier and user's institution id to ensure that I have the right mental model

Process

I use vim to type out my thoughts and save them a text file. I could see marking things off by putting ’#’ at the beginning of the line, which for me would gray the line out, but normally I just delete things when I get done. This results in a nice feeling of crossing things off of the list. If I’m in the heat of solving a problem, I often don’t write or delete lines. But when I come to a stopping point or am considering what next to do, I usually write out what I am thinking. This minimizes overhead and preserves flow.

A Tangent

The subject in the first line is the git branch that I am currently working with (I typically use description-datetime-created as the branch format.) If there is a need to switch branches, then I keep this stream around to remind me of the current state of the problem.

A script named cb (create branch) is how I usually create branches now with git:

#!/usr/bin/zsh
zmodload zsh/datetime
git checkout -b $1-`strftime "%Y%m%d-%H%M" $EPOCHSECONDS`

Then cb branch_name results in a new branch called branch_name-YYYYMMDD-HHMM. If there is an easier way to query the time a branch was created, I’d be interested to hear it.

Benefits

Constantly specifying the next thing that I need to do or resolve has the benefit of keeping me conscious about what I am doing. While I saw this with the pomodoro technique (“how does what I’m doing relate to the current pomodoro?”), this makes the process more explicit. I can easily track my problem-solving process and see where I might have gotten into some rabbit holes. Sometimes I just find myself looking at a file and realizing that I have no idea how I got there. Whenever I find myself in that situation, I immediately switch to the stream file and reorient myself to the problem I’m currently trying to solve.

Another benefit of the streaming technique is being able to jump back into problem solving after breaks and interruptions. There are times when I can come back to the computer and see where the cursor is in the file and know the next thing to do, but it normally takes awhile to load the problem into my head. Reading through my thought process seems to decrease this ramp up time. Perhaps just writing down how I am approaching the problem makes things clearer for me the next time.

It seems like the problem solving process can generally be best represented as a stack, so I try to reflect this with indentation. Sometimes it forms a bit of a tree structure, but this is likely a problem-solving smell. If a new line does not fit cleanly under the main heading, then I examine the new direction carefully. As a result, I tend to be more aware of when I am considering something that might increase work in progress. Perhaps this task should be considered later, or maybe I should create a new branch before trying to implement this change. Seeing a very long chain of things might indicate that I have too many questions or am not breaking work up effectively.

Like I said, it’s new, so I haven’t worked out all the kinks. But so far it has been well worth any trouble. Let me know what you think if you try it out for a day!

Categories: main

« Meaningful conversations Review: Getting Real »

Comments