Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Think Twice, Code Once

Think Twice, Code Once

These are the slides for my presentation at Mountain West Ruby Conference. I removed the speaker notes before I went on stage so the actual presentation was a bit different but I've retrieved the notes from my time machine backup so that the slides have context.

Bill Chapman

April 06, 2013
Tweet

More Decks by Bill Chapman

Other Decks in Programming

Transcript

  1. Saturday, April 6, 13

    View full-size slide

  2. Code Is Poetry
    Saturday, April 6, 13
    The right side of my brain make things rhyme
    The left side keeps it in time
    Whats in between helps me learn and perceive
    But do I Believe,
    I have the answers I need?
    Ours is a culture of logic and reason
    But do the ones and zeros truly have meaning
    Does your software have feelings?
    Stay Tuned
    This may be revealing
    Work harder they said
    We can rest once we're dead
    What is the Opportunity cost
    Of this lack of mental floss?
    So many questions and no time for thought
    Maybe you should sleep on it
    Let rapid eye movements give way to improvement
    Solutions reduced to abstract illusions
    Fast asleep and hard at work
    Generate painless solutions
    So we've chosen our tools
    We've lined our minds with patterns of design
    Muscle memory translates brain waves to square braces
    And a faint blue glow on end users faces
    Blue glows become blue screens
    and sad macs bombs and disasters
    Did we fail to think or fail to see

    View full-size slide

  3. Think twice, Code once
    Clever Subtitle that I didn’t have time to think about
    Saturday, April 6, 13

    View full-size slide

  4. Who am I?
    • Bill Chapman - [email protected]
    • @byllc
    • Development Lead @ Academic Software Plus /
    Liaison International
    • Partner @ Division by Zero
    • Co-Founder WNYRuby, Co-Organizer Nickel City Ruby Conf
    Saturday, April 6, 13
    I am a development lead for Liaison International
    I consider myself a professional thinker.
    15 Years professional programming and technical consulting experience
    Currently my most important role is that of a team mentor

    View full-size slide

  5. Who is Janey?
    • My dog
    • Destroyer of shoes
    • Exfoliator of faces
    Saturday, April 6, 13
    Janey appears to run on intutition. Trust me, Janey thinks she’s an expert in everything and
    I get an earful of it every time I come home late.
    But for experts in a subject matter sometimes it is difficult to resist the urge to rely
    completely on intuition.
    PMTAL, Andy Hunt - dreyfus model - how individuals acquire skill.
    Novice, Advanced Beginner, Competent, Proficient, Expert.
    most never get beyond the Advanced Beginner state.
    Think about that, by this model everyone in this room is less than competent at most things.
    dunning-kruger the inexperienced tend to over estimate their ability and this implies that
    when we are advanced beginners we probably don’t realize it.
    I introduce this here to make a single assertion.
    For any given problem that you have not yet solved, you are not yet an expert in that
    problem.

    View full-size slide

  6. Saturday, April 6, 13
    Often as a project “founder”. Someone who has written a lot of the original code. I’ve thought
    through many of the solutions we have to implement. My brain has been working on it for
    months or years. Because of this sometimes delegation can be hard.
    Anecdote about getting frustrated because it takes others longer to ‘code’
    Anecdote about waiting for inspiration

    View full-size slide

  7. Saturday, April 6, 13
    People who might benefit from this discussion.
    (Programmers and Persons other than programmers) POPES

    View full-size slide

  8. The Freshman
    Saturday, April 6, 13
    Example from the interview we did recently. The code worked but it looked like a freshman cs
    101 project. You can tell when someone doesn’t think the problem through completely.
    Or a prospective new hire may submit a code quiz result where the tests all passed but they
    don’t bother to look for cases we didn’t test forDoesn’t necessarily understand why the
    solution works.

    View full-size slide

  9. Saturday, April 6, 13
    A key part of the freshman mentality is that they don’t really what is important. The rest of
    this project had tons of these screens.
    Deficiency is they have not yet learned to think through problem carefully or they don’t see
    the importance in and even if they did they don’t always know what is important.

    View full-size slide

  10. Mrs. Roberts
    Saturday, April 6, 13
    Another individual who might benefit from this discussion.
    Often patches a problem because they think the bigger issue is too complex o
    even unsolvable
    This approach tends to create gremlins in the code base. (Bobby tables jr)
    Looks productive to management because they always ‘solve’ the problem,
    Management might not realize that the keep solving the same problem.

    View full-size slide

  11. Saturday, April 6, 13
    Here is some of Mr. Table’s work.
    Apparrently she had some no method errors to deal with and he appears to have swept them
    under the proverbial rug.
    This can cause some pretty nasty problems to be hidden from other developers.
    Deficiency: They are solving the wrong problem by not thinking about the
    bigger context of their problem

    View full-size slide

  12. The Bob Ross Fan
    Saturday, April 6, 13
    Tosses code at the problem until it works.
    No one else knows what they are up to and all of the layers of code make it difficult to see the
    bigger picture.

    View full-size slide

  13. Saturday, April 6, 13
    Its hard to find an example of this style of code because the end result is often deceptive. It
    looks well structured. You’d almost have to just hit ctr/cmd z after they were done typing for
    awhile.
    Deficiency: They don’t spend so much time thinking about their solution as much as chasing
    their intuitive vision.

    View full-size slide

  14. The Mercenary
    Saturday, April 6, 13
    Is somehow able to shut their brain off at 5pm. Cares about whatever language knowledge
    pays well.

    View full-size slide

  15. Saturday, April 6, 13
    This mercenary would list ‘ruby expert’ on their resume. Sure it is valid code but it doesn’t
    really look like ruby most of us would write.
    Deficiency: They care more about doing the job than using the right tool or really learning the
    ones they are using.

    View full-size slide

  16. Pointy Eared Boss
    Saturday, April 6, 13
    Doesn’t always understand what you do.
    Thinks they know what “working” looks like
    Wants to quantify what you do.

    View full-size slide

  17. Saturday, April 6, 13
    deficiency is that they often focus on irrelevant metrics to
    evaluate the work you are doing.

    View full-size slide

  18. Get to the point already!!!
    Saturday, April 6, 13
    We are professional Thinkers.
    And Thinking happens everywhere, it follows us home and invades us in the shower.
    Interrupts other conversations and thoughts.
    We do it over dinner, much to the chagrin of our significant others.
    Thinking is really what we are getting paid to do. and personally I think coding is the easy part.
    1. We spend a lot of time honing our code craft. Learning new programming languages, discussing esoteric
    points of some framework, doing code katas. Do we spend enough time keeping the right tools sharp? Are
    we keeping our minds healthy?
    Also The best place for thinking is not necessarily the best place for coding. Have you ever tried to code in
    the shower? Are we providing ourselves with the best environment for getting our job done? Are our
    employers and clients?

    View full-size slide

  19. Saturday, April 6, 13
    I’m not talking about big up front design or aggressively detailed specification. Whatever the
    term agile actually means, I consider my current team to be pretty good at the important
    parts of it.
    This is more about giving ourselves time to think, doing thinking at the right time,
    understanding that unconscious thought has value and factoring it in to our plans. The end
    result of both active and passive thought is not necessarily going to be a specification nor is it
    always going to fit in to a culturally acceptable work day.

    View full-size slide

  20. Saturday, April 6, 13
    So how can I convince YOU and the rest of my intended audience that coding is the easy part.
    We probably spend too much time focusing on what should ostensibly not a majority of the
    work we do.
    I think there is plenty of precedent already.
    Architecture Roles for best thinkers
    TDD Style Development (Thought Driven Development)
    Employment agreements that discuss work done on personal time: What the employer is
    saying is that we are paying you for your thoughts, all of your thoughts, whenever they occur.
    As soon as they manifest themselves as a concrete piece of code we own them.

    View full-size slide

  21. Saturday, April 6, 13
    So let us assume that I’ve won you over. I don’t think this assertion is a stretch. It’s probably
    not even that interesting. Lets pay more attention to the actual act of thinking and see what
    some other professional thinkers have to say about it.

    View full-size slide

  22. Saturday, April 6, 13
    This is Poincare (Pwan care ay)
    I’ve read that Poincaré … worked regularly from 10 to 12 in the morning and from 5 till 7 in the
    late afternoon. He found that working longer seldom achieved anything …
    A four hour work day for a significant mathematical mind working on very difficult problems
    (the poincare conjecture was one of the seven millenium prizes)
    Sure  this  is  anecdotal  Well  Recent  research  from  Florida  State  University  seems  gives  us  more  to  
    consider.    The  subjects  were  elite performers, including musicians, athletes, actors and chess
    players.  The  best  performers  typically  prac?ced  for  no  more  than  90  minutes  per  session    Taking  
    regular  breaks  and  rarely  working  more  than  4.5  hours  in  a  given  day.
     This  study  asserts  that  during  the  day  we  move  from  alertness  and  into  mental  fa?gue  approximately  
    every  90  minutes.    It  is  at  these  fa?gue  points  that  we  may  feel  like  we  need  to  compensate  with  
    caffeine,  sugar  or  other  s?mulants  when  It  is  likely  that  all  we  really  need  is  to  goof  off  a  for  a  bit.  
     Our  coworkers  may  not  understand  why  we  have  nerf  guns  loaded  and  at  the  ready.    
    We know that under some circumstances (e.g., Wilson & Schooler, 1991), conscious thought
    deteriorates the quality of decisions.
    Question: Are you working too much?

    View full-size slide

  23. Saturday, April 6, 13
    4.5 hours a day doesn’t seem like much time to get anything done.
    What about the rest of the day?
    There has been a great deal of research in Unconscious cognition: http://en.wikipedia.org/wiki/Unconscious_cognition
    Have you fallen asleep thinking about something only to wake up with the answer?
    Apartment study, one apartment significantly better. Subjects asked to choose immediately or choose after a period of
    being distracted by doing some other task. The distracted group chose correctly almost twice as often as the group
    asked to choose immediately
    This finding that has now been replicated a number of other studies (see Strick et al.,
    2009, for a meta-analysis)
    The implication here is that their brain was working on the problem, even though they were engaged in other
    activities.
    Question: So we are always working on some problems whether we like it
    or not?

    View full-size slide

  24. Saturday, April 6, 13
    In another study participants were asked to recall a list of related words. On
    group was asked to recall the list after 8 hours of sleep. One group was asked
    recall the list after 8 hours of waking relaxation. The waking group forgot 25%
    more of the list than the sleeping group.
    Question: Wait! You mean even when we are asleep we are still working and
    possibly even working harder on some problems?

    View full-size slide

  25. Saturday, April 6, 13
    But what about getting things done? Other research implies that there is a divide between
    the thinking mindset and the doing mindset and that you can only really be in one state at a
    time. Furthermore, some individuals spend more time in one state than in the other.
    Maybe we shouldn’t try to fight our current state and choose tasks that fit our current mental
    mode.

    Question: How do we optimize our mental state for the task at hand? Also how can we
    allocate our teams based on their common states?

    View full-size slide

  26. Saturday, April 6, 13
    But what about when we are actively thinking?
    It is often stated that we only have a finite space for remembering concurrent ‘things’.
    (7 Things +- 2) Millers Law
    But I think programmers routinely solve problems involving hundreds or thousands of
    variables.
    Question: If we can only have finite working memory space how can we
    possibly keep track of the hundreds or thousands of variables that go in to
    solving complex problems?

    View full-size slide

  27. Saturday, April 6, 13
    Along the same lines as thinking vs doing there is also possibly a separation of different
    modes of thinking.
    Peter Elbow is a well known researcher and writer and his theories on writing have become
    recognized as fundamental components to teaching others to write well. We have very
    different modes of thinking.
    A creative thinking mode and a more linear and directed mode. He asserts that each of these
    modes are incompatible. Furthermore trying to do both editing (linear and directed activity)
    and Creative writing is detrimental to the process. His recommendations are to either do
    each activity in separate sessions or to have separate individuals perform each task
    altogether. I think it is not a stretch to apply these same ideas to the work we do.
    My personal experiences with pair programming where the pilot focuses on coding and the
    copilot thinks through the big picture have shown good results. I’ve talked with quiet a few
    developers who share this experience.
    Question: Do we understand the strengths and weaknesses of our thinking modes and how
    to utilize them? Do we know how to best utilize our teams?

    View full-size slide

  28. Saturday, April 6, 13
    I’m doing a talk about thinking but In a lot of ways what we are really talking about is
    problem solving. That is the full function of our roles as programmers.
    I started out with an assertion that for any given unsolved problem, you are unlikely to be an
    expert in that problem. Otherwise it would be solved already, realize that you may have to
    learn something before you come to a solution.
    Think, Learn, Apply. This is a process of acquiring knowledge and immediately applying it to
    acquire more knowledge.
    Question: Considering that learning is a key part of problems solving, what can we do to
    make sure we are also providing ourselves with a good learning environment?
    - Go to the white board,
    - Mind Mapping
    - Debating
    - Sketching
    - Role Playing a System
    There are many different ways to acquire knowledge. The three main pathways are
    considered to be Auditory, Visual and Kinosthetic learning.

    View full-size slide

  29. Saturday, April 6, 13
    Several studies assert that Activating more of the brain while engaged in thought has shown
    to increase mental productivity and effectiveness. Even if the extra activity has nothing to do
    with your current task. Spinning a pen around your thumb for example tapping your foot.
    learning with legos etc...
    Music is an excellent multi sensory stimulant. It can engage the aural, kinesthetic,and even
    visual centers in your brain.
    Surgeons Playing Music
    Fresh Prep,
    29 students who failed regents exam. After a 12 day fresh prep 79% passed including 100% of
    the special needs students and this past summer This past summer, 83% of students passed the
    course.
    The anecdote about acting out a system from PMTAL
    Question: What can we do to augment our approach to problem solving?

    View full-size slide

  30. Saturday, April 6, 13
    Wildcard: neuro genesis - ability to regenerate brain cells
    We may have the capability to generate new brain cells throughout our lives but the
    environment we work in plays a big role in whether we are growing or killing. Active, thought
    nurturing environments demonstrate an ability for brain cell growth.
    Much of the brain cell studies have been done on mice because most research is not done by
    Hannibal Lecter. For years subjects would show a decline in brain cells and brain function that
    seemed to correlate with age.
    New research indicates that it may have been that the mice were living in plain, non
    stimulating environments. Without much neuro-stimulation their brains would decline but
    mice that have been raised in environments with significant stimulation showed less or no
    decline at all.
    Question: Does constant exposure to dull, repetitive environments sound at all like your work
    place?

    View full-size slide

  31. We’re sorry Mario but
    your answers are in
    another castle
    Saturday, April 6, 13
    The concept of being ‘busy, working’ now becomes a gray area.
    Should we leave more time for active socialization or personal relaxation in our work day?
    Maybe we shouldn’t get bogged down in the work until the work is done mindset. If you find yourself stuck on a problem maybe you
    are in the wrong mindset for your current approach.
    If we only have so much working memory capacity we must whittle down a problem in to smaller and smaller abstractions. Doing this
    completely could require a great deal of top down thinking.
    Do you know how each of the members of your team prefers to learn? Do you know how you prefer to learn? Problems solving is
    thinking/ and learning iteratively.

    View full-size slide

  32.  undefined  method  `foo'  for  nil:NilClass  (NoMethodError)
    • Why? : The receiver doesn’t respond to ‘foo’
    • Why? : The receiver Is nil
    • Why? : I’ve made assumptions that the receiver is present
    • Why? : The receiver really should not ever be nil
    • Why? : Because we have bad data
    Saturday, April 6, 13
    Just talk the 5 why’s the highlighted middle, why the five why’s overcomes this, this is bobby tables and freshman territory. Than talk about the
    last itme
    The 5 Whys is an iterative question-asking technique used to explore the cause-and-effect relationships underlying a particular problem.[1]
    The primary goal of the technique is to determine the root cause of a defect or problem. (The "5" in the name derives from an empirical observation
    on the number of iterations typically required to resolve the problem.)

    View full-size slide

  33. git clean -d -x -f; git reset --hard
    Saturday, April 6, 13
    Returning to the poincare example. His four hours of work was also probably 4 hours of fairly intense thought.
    There are plenty of less intense activities that we can be involved in during the day.
    We’ve discussed different states of thinking and learning
    If we are in a working mode it doesn’t mean we are ready to code the thing we are currently
    thinking about
    Try to be aware of your current mental mode and match your tasks appropriately. I personally
    know that I am a much better at “doing” once my brain has settled down for the day. Before
    managing a 9-5 team I used get massive amounts of coding done between 8pm and
    Midnight. Now that I spend more time as a mentor, I get to do more thinking or being the co
    pilot when I’m best at that stuff during the day.

    View full-size slide

  34. Saturday, April 6, 13
    Stop Taking on Too Much
    Recognize that we need time to think through problems. Bouncing from one problem to the
    next or one project to the next means we get none of this passive “work” time. If you find
    yourself in this position you may want to think about coding even less.
    At times In my life I’ve been engaged in 5 or 6 professional software projects. In my
    experience, just because you can do one project in one month, that does not mean you can
    do 6 projects concurrently and finish in 6 months. I believe this is because your unconcious
    cognition has limits.
    Figure out how much time you want to devote to work and then realize that that time is not
    just time spent on the computer. Plan for thinking time and avoid grinding away at code.
    Many of us consult, have day jobs or take on way too many clients. If we only have a few
    good thinking hours in the day this may effect they way we allocate tasks in a given week.

    View full-size slide

  35. Saturday, April 6, 13
    Recognize Environmental Constructs
    The best place to think is not necessarily the best place to code.
    Do what you need to do to keep your mind healthy. If that means pushing for more remote work orworking
    towards a more flexible office culture.
    The computer is a distraction machine.
    When you sit in front of a tool, the instinct is to be using it. But what if you are in Thinking mode?

    View full-size slide

  36. Saturday, April 6, 13
    Sleep On It
    This doesn’t necessarily mean take a nap.
    Take a walk, Talk about the last episode of Eureka,
    Stare out of the window blankly .
    Do something that is not active coding, Give your brain a chance to do its thing. Let it catch up to your
    code

    View full-size slide

  37. Saturday, April 6, 13
    So we all have a lot of decisions to make, every day. Like which restroom to use

    View full-size slide

  38. Saturday, April 6, 13
    And Sometimes a little bit of analysis can go a long way.

    View full-size slide

  39. Books and Further
    Research
    • Pragmatic Thinking
    • Thinking Fast and Slow
    • Smart Thinking
    • George Miller
    • Peter Elbow - Writing with Power
    • Eric Ivancich - Effective and Creative Coding
    Saturday, April 6, 13
    Other referneces:
    http://www.psych-it.com.au/Psychlopedia/article.asp?id=59
    http://learnruby.com/presentations/Ruby-Life-Hacks.pdf
    h"p://calnewport.com/blog/2012/08/31/henri-­‐poincares-­‐four-­‐hour-­‐work-­‐day/
    h"p://calnewport.com/blog/2012/08/23/you-­‐probably-­‐really-­‐work-­‐way-­‐less-­‐than-­‐you-­‐assume/
    http://en.wikipedia.org/wiki/Unconscious_cognition
    http://ideas.time.com/2012/09/12/does-listening-to-music-while-working-make-you-less-productive/
    http://leadershipsuccessinc.com/recent-posts/item/thinking-vs-doing-mindsets-make-the-most-action
    (e.g., Wilson & Schooler, 1991)
    (Bos et al., 2009)
    (see Strick et al., 2009, for a meta-analysis)

    View full-size slide

  40. Attributions
    • Wikimedia Commons
    • XKCD
    Saturday, April 6, 13
    I’m not sure what the attribution is for memes.
    Derivative Works?

    View full-size slide

  41. Answers?
    Saturday, April 6, 13
    So I’ve got time for a couple answers if anybody has any

    View full-size slide