How Ideas from Human Psychology can help Programmers?
Do you want to program at your peak performance? Do you want to enjoy programming job? What are the tricks to get unstuck from hard problems? How can you push your cognitive capabilities? Turning into Psychology can tell us answers.
Like a hero of a movie, the programmer’s life has villains, diversions, fights, and emotions. Are you ready to become a programming hero?
1. Achieve Flow State
In the famous book Flow: The Psychology of Optimal Experience, Psychologist Mihaly Csikszentmihalyi reveals that the secret for achieving Peak Performance is doing work in an optimal state called flow.
Flow is optimal state of consciousness where we feel our best and capable of performing at top level. During flow, people typically experience deep enjoyment, creativity, and completely involved in an activity for its own sake.
Flow also happens when a person’s skills are fully involved in overcoming a challenge that is just about manageable, so it acts as a magnet for learning new skills and increasing challenges.
To achieve a Flow state, you got to balance between the difficulty of the activity and your skills.
Learn the skills in advance ✅
If your work requires a new skill (may it be a new language or technology etc..), don’t try to learn and do the work simultaneously. Being familiar with it would avoid anxiety and help attain flow state. So, learn skills in advance to ensure you have the right level of skills for the challenges in the project.
Make it work first, then make it perfect ✅
The challenge will be harder if you try to write perfect code and you might get stuck. So to reduce the challenge, just write the first version of the code that works without worrying about it being bad. Then, it will be easier to refactor and make it good.
Divide and Conquer ✅
Another trick is to break up your complex work into small manageable tasks so that you will have control.
So the idea is to level up your skills or decrease the challenge to attain flow state. Game designers use this technique to keep the players hooked. They make the difficulty of game levels appropriate to the player’s skill so that players neither feels frustrated and nor bored. In the flow state, programming will feel like playing a game.
💡 If you achieve flow state you will be the hero. But wait, there is a villain.
2. Win Focus
Flow experience may not occur in the first few moments and you will need to stay focused to get immersed in the work. Cal Newport takes about the importance of focused work in his book Deep Work: Rules for Focused Success in a Distracted World
Deep Work: Professional activities performed in a state of distraction-free concentration that push your cognitive capabilities to their limit. These efforts create new value, improve your skill, and are hard to replicate.
Set aside time for Deep Work ✅
You can set aside some time for focused work. To avoid distractions, turn off all notifications on your computer and phone. If you are not good at self-control, try Pomodoro technique.
Pomodoro Technique ✅
Pomodoro technique provides a system to perform deep work.
Basically, you work on a task for 25 minutes with zero distractions. Then, you take a short 5-minute break and move on to next Pomodoro. After 4 pomodoros, you can take a long break. You can easily find Pomodoro apps on the internet.
💠 Don’t be too strict with Pomodoro schedule. If you are in a flow state, you don’t have to force a break when the 25 minutes is up. But there are other good times to take a break for a walk which I will discuss later in this post.
This is great for external distractions. what about internal mental distractions?
Commit your thoughts ✅
Our mind usually gets distracted by thoughts of unfinished tasks, regardless of their importance. Because open tasks tend to occupy our short-term memory until they are done.
But thanks to Zeigarnik’s follow-up research. We now know that,
We don’t actually have to finish tasks to convince our brains to stop thinking about them. All we have to do is to write them down in a way that convinces us that it will be taken care of.
After your work, you should not only commit your code to source control — But also write down your thoughts (e.g next steps, todos etc ) in a good place.
💡 A programmer’s journey not only has villains but also diversions and interruptions.
3. Minimize Choices
The life of a programmer involves making a lot of decisions and it interferes experiencing the flow state.
In his book The Paradox of Choice, Barry Schwartz describes how more choices lead to anxiety. He used numerous examples, from shopping to career options to romance, to show that less choice can not only increase our productivity but also our freedom and make it easier to be in the moment and enjoy it.
He was primarily studying the behavior of shoppers but the same principle applies to programmers. We can use some techniques to reduce the number of decisions we have to make.
Think about it when picking a language or framework ✅
Many people admire the Go language because there is only one way to do something (like writing loops). Also, one of the reasons that people hate the Perl language is there are too many ways to do the same thing.
So consider the benefits of flexibility vs restriction when choosing a language or framework. If there is the only way to do something, you don’t need to worry about enforcing best practices.
Collect essential materials up front ✅
Programmers often have to look up code examples or documentation to do the work. This not only causes context switching but also creates a burden to pick a right example or API.
So, collect the necessary materials in advance so that you don’t have to look through the numerous google results and decide the right one.
Have a design before writing code ✅
Try to make the important decisions and design before you begin writing your code. This will help you focus on solving the problem at the hand instead of wasting your energy in making decisions.
💡What If I have procrastination or got stuck on a problem? Do you need a fight?
4. Don’t fight against Willpower
Studies on highly successful people have proven that success is not the result of strong willpower and the ability to overcome resistance, but rather the result of smart working environments that avoid resistance in the first place.
There some techniques to avoid the fighting against willpower.
How to avoid Procrastination?
Instead of forcing ourselves to do something we don’t feel like doing, we need to find a way to make us feel like doing what moves our project further along.
Have well-defined tasks ✅
The primary reason for procrastination is defining your goal at high level. Writing down specifics of what will you do, when and where to do it provides far more chance for actually doing it. Also, your brain thinks it’s too hard if there are not enough details. So having a meaningful and well-defined task beats willpower.
Head start on next task ✅
People usually take a break or call it for the day when they are done with a task. But, it's a good idea to begin or make slight progress on the next task. Because you would have a better idea of what to do when you start your work on the next day. This will help you avoid procrastination since you are not starting something new.
The same idea can be used while reading a book. Instead of closing a book when you are done with a chapter if you just read the first page of next chapter, you are likely to pick up the book again.
How to Get Unstuck in solving hard problems?
Similar to willpower, you don’t have to think hard to solve a tough problem. You can tune your mind so that solutions can come automatically to you in surprising ways!
Break for a Walk ✅
Letting thoughts linger without focusing on them gives our brains the opportunity to deal with problems in a different, often surprisingly productive way. While we have a walk or a shower or clean the house, the brain cannot help but play around with the last unsolved problem it came across.
So you will likely get an idea if you simply walk away from your computer.
Sleep on it ✅
Go home with an unsolved problem. Don’t try to force yourself to solve it, instead just sleep. Your subconscious mind will work on it and you will likely have a solution in the middle of the night or when you wake up in the morning. Many times solutions for my problems appeared in middle of the night or first thing in the morning or during my shower.
Try to work on different problem or project. ✅
Sometimes solutions to problems come automatically when you are not thinking about it. So, instead of pushing against a hard problem, redirect your energy towards another productive goal. With this method, to work on different things simultaneously, you never encounter any mental blockages.
💡 There is still something missing. Life becomes beautiful only if there are also emotions. Similarly programming too.
5. Practice Empathy
Empathy is an important skill that will lead to greater success and happiness in personal life and profession. Practice empathy in programming too. Programming is not just logic. It is expressive like an art.
Write maintainable code ✅
Keep in mind that the code you write will be read and maintained by others.
Programs must be written for people to read, and only incidentally for machines to execute ― Harold Abelson, Structure and Interpretation of Computer Programs
Follow the best practices of coding style like meaningful variable names, smaller methods etc. You shouldn’t program look like in this comment 😃
//When I wrote this, only God and I understood what I was doing //Now, God only knows
Make sure code you write has a low cognitive load for other developers so that it’s easy to maintain. Write useful comments. Here is a funny comment I came across 😆
// Dear maintainer:
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// total_hours_wasted_here = 42
Use simplicity in design ✅
Whether you are designing an API or user interface, make it easy for your users. The basic principle you can follow is
Simple things should be simpler. Complex things should be possible.
Practicing empathy will not only help you but also make your team productive and users happy.
You may be already using these techniques. But knowing reasoning behind them using psychology can help you do them productively.
If you hate programming or considered quitting, using these ideas from psychology might transform you as a happy programmer.
When you see programming through the eyes of psychology, you will appreciate it’s beauty and enjoy the art of programming.
Thanks for reading.
Top comments (3)
Great article. I’m a flow junkie. You can read my flow guide for devs here.
I can also vouch for most of the techniques here. Especially sleep on it!
interesting article ! thanks
Thank you for these nice tips! They are really helpful! I also trying to find more info for my psychology research and your article helped a lot.