Google
 

Thursday, October 30, 2014

Inside of the developer's mind

As software developers, we give special care to learning and mastering our tools, whether they are IDEs, libraries, technologies, or design patterns.
But we forget about the most important tools that we use: mind and memory. And in our continuous challenge to learn new things, our understanding of how mind and memory work is essential.
In this post I would share some knowledge about how memory works and try to explain how does this relate do our job as developers.
I’ve learned many of the concepts I’ll mention here from a great MOOC: Learning How to Learn

First, I will share with you few concepts about memory.

Human Memory

If you remember from computer science classes that you might have attended, computer systems have different types of memory. Each type of memory is used for a different type of tasks and have different characteristics.
For example registers are used for performing calculations in the processor. While hard disks are used for long term memory storage.

Surprisingly human memory works kind of the same. we have a working memory which has limited number of slots (4 to be more specific). It’s used for problem solving and to process things that require concentration like debugging and writing new code.
This memory is highly volatile. you need to concentrate to keep things active in it and stay conscious or you’ll lose them. Some times you need to repeat things few times in order for them to stick even for a short period just enough until you get to use it (imagine remembering a bug id from an issue tracking system just for a few seconds till you get to your machine). Sometimes you even close your eyes to disallow distractions from wiping it off.

On the other hand, long term memory is used to store huge amount of information but also is harder to retrieve data from. Long term memory is essential for learning, imagine that you need to learn everything from scratch again and again, you’ll not make a noticeable progress.
Same as computers work, we need to retrieve information from long term memory into the working memory to process them. So both types are connected.
So how to support your long term memory to store and effectively retrieve information when needed?

Long term memory is like a huge warehouse, where billions of things (information, memories) are stored, and these things can bury each other. To be able to retrieve them later, you need to practice retrieving them. This practice reinforces the synaptic connections that form the memory. This time, unlike Hard disks, if you don’t practice the retrieval process, you’ll not be able to find the information when you need it.
In addition, to reliably store new information, you need to give it some time so the bonds get stronger. So just repeating a piece of information several times in a short period of time (minutes or hours) won’t get it into the long term memory.
Spaced repetition is a technique used to practice the retrieval process over an increasing time intervals. For example, when you try to memorize something, you read it today, tomorrow, two days later, a week later, a month, and so on. These intervals are determined based on the difficulty of the topic and whether you’re able to recall it or not.

One great tool that employs this technique is Anki. You feed it with index cards or use a card deck from its gallery and start studying these cards. It will handle the spaced repetition, it will show you the cards that you’ve studied when it feels it’s the right time. Smart isn't it? And by the way, it has web, desktop, and mobile editions.
So the next time you find yourself unable to remember the name of a design pattern, try Anki. Some kind people contributed to the shared decks with design patterns decks. Or even better, make your own and contribute them.

Procrastination

Software development is fun, or so it should be. Good developers are driven by challenging problems and curiosity. But times come when we have to do boring tasks that we want to put away but we can’t as they are part of the job. What are you whispering? Writing documentation? Yes, this is a good example.
When we are required to do some tasks that we don’t like, we tend to procrastinate, find excuses to do other less important things at that time, or remember that it’s the time for a cup of coffee and some socialization.
Why? It’s because of how our brains work. When we are faced with a task or a problem that we don’t like to do, this activates areas in the brain that are associated with pain. It’s a normal reaction that brains do some tricks to avoid doing them. Thus avoid the pain and feel temporarily happier, till deadlines approach, and bosses start to get angry. Even worse, the more you procrastinate, the more painful the task gets. Similar to addiction, short term happiness, but long term loss.
What’s interesting is that if you actually start working on the task, the pain goes away! So it’s all about coming over the cue that activates the procrastination behavior.
Procrastination is a bad habit, and we want to replace it with a good habit that make us more effective. So what are the components of habits?
  1. Cue: This the trigger or event that starts the flow of the habit. For example, a distraction from social media or an email notification. Or a checking your task list to find that documentation task.
  2. Routine: The reaction to the cue. For example, finding somebody else’s task that your task is pending on in order to avoid it. Admit it, you’re good at this :)
    A good routine might be a positive self talk followed by a time-boxed duration to get things done. I’ll tell you later about a good tool for this.
  1. Reward: Maybe this is what’s dangerous about procrastination as a habit, it gives immediate reward which is removing the pain and doing something more pleasant. So key to building a good habit is to reward it, maybe with a quick technical chat with a geek like you about a hot technology. Or a cup of coffee.
  2. Belief: Our beliefs about what’s good and what’s bad, what’s useful and what’s not. To tackle procrastination, you need to understand and believe that it has a negative long term effect.

To put this into action, Pomodoro is a very effective technique of handling procrastination. Pomodoro is the Italian word for tomato . This is how it works:
  1. Disable any interruptions. (No unwanted cues)
  2. Focus on a task for a short period, 25 minutes by default, which is not too hard. As I mentioned before, once you start, the pain goes away. Use the timer for this.
  3. Give yourself a 5 minutes break as a reward. You can get your cup of coffee now. Again, use the timer.
  4. Start the next 25 minutes of focused work and repeat.
  5. Give yourself a longer break after say 4 pomodoros.
This technique is very useful and proven. You can find mobile apps that employ this technique to help you manage your pomodoros and track them.

A pomodoro timer, from http://en.wikipedia.org/wiki/File:Il_pomodoro.jpg


In addition, you need to focus on the process of the task, rather than focusing on the outcome (the product) that triggers the pain.
Try to get into the flow mode which gets the best out of your concentration and focus. Have a look on this talk to know more about it.



Mark Seemann - Zone out, check in, move on from NDC Conferences on Vimeo.


Focused and Diffuse modes of thinking

We’ve all had time struggling against a weird bug or trying to find a solution for a complex problem, but no good. Trials after trials, hours after hours, Googling, tweaking, and squeezing your mind to the last drop of good ideas, and it all seems as if you’re slamming your head in the wall.
We’re all about focus, but focused mode of thinking won’t always get you where you want. It sometimes limits the space of your brain where you’re searching for the solution. It keeps finding the ideas that you’re familiar with, which might be the reason why you’ve got into this buggy situation in the first place. Or the reason why you can’t figure out the best design for this novel problem. Similar to how greedy algorithms sometimes can’t find the optimum solution by being stuck into a local minimum or maximum.

Local maximum and minimum. From http://en.wikipedia.org/wiki/File:Extrema_example_original.svg
So, should you give up? No, you should just switch to a different mode of thinking , the diffuse mode, which allows you to explore wider solution spaces and form new connections in your brain that finally formulate the solution you’re looking for. How to do the switch? It’s easy. Get away from the computer’s screen, leave your desk, have a walk and take a breath in the fresh air. Do this while giving yourself a chance to think about other things that might not be directly related to your problem. Looking into the big picture and seemingly unrelated areas will explore wider areas of your brain’s memory and will help you getting the solution.

Note that these two modes of thinking cannot be used simultaneously. You cannot be in both states at the same time. So you might need to go back and forth between focused and diffuse modes in order to find an innovative solution or understand a difficult concept.


Summary

Understanding how your brain works is essential to your career as a software developer. Ability to learn and understand new concepts and use that understanding in the right place and time is a cornerstone in your arsenal of skills.

3 comments:

Anita Grey said...

It was a pleasure to evaluate your work! thank you!

Anita Grey said...
This comment has been removed by the author.
Hesham A. Amin said...

Thanks Anita :)