Table of Contents
- Be persistent
- Be patient
- Understand the problem
- Break it down into smaller parts
- Start as soon as possible
- Review and reflect on your work and learn from it
- Epilogue: How to think like a programmer
All expert programmers have one thing in common. They share the same problem-solving mindset and thinking patterns. This is what distinguishes them from beginners. Use these tips to develop this mindset. Learn to think like a programmer to become a better programmer.
How to Think Like a Programmer Part 2.
This is the most important things you have to learn if you want to learn how to think like a programmer. Whatever your situation is you have to be persistent. Persistence is one of the key attributes of expert programmer’s mindset. Any experienced programmer will tell you that almost nothing works on the first try.
It doesn’t matter matter what problem you want to solve. You will usually need to try at least few ideas and approaches before you find the right one. And, even when you find the right one you will still probably need to spend some time debugging and polishing it. This is why being persistent is so important.
Reject giving up
If you want to learn how to think like a programmer persistence is the thing you have to start with. No matter what the problem or challenge is, reject the idea of giving up. Reject the idea of not trying again. Remember that, given enough time, brute force always works. You just have to be patient, persistent and try long enough.
So, when you take on some new challenge, be willing to push yourself beyond your limit. Be willing to work on that challenge until you solve it. It might take a few minutes, hours or even days. That doesn’t matter. Don’t give up. Don’t move on to something else. That is simply not an option. You have to keep pushing yourself, trying different ideas.
It is often when you feel exhausted, drained, and ready give up, when you finally find the solution. When you figure it how to solve that tricky problem. This is why only so few people succeed, why there are only few really good programmers. When times get tough, when you feel you are hitting the wall is the moment where most people give up.
Unfortunately, this is also the moment you need to keep going because this is when you improve and learn. It is at those moments when you feel frustrated, when you are on the verge of exhaustion, where you can make the most significant progress. This is also why expert programmers regularly, sometimes constantly, look for challenges.
Start looking for uncomfortable situations and challenges
Expert programmers know one thing. Everything that feels uncomfortable is a gift in disguise. These situations are opportunities for learning, growth and making progress. They are opportunities for improving your skills and also your character. If you want to learn how to think like a programmer you have to stop avoiding challenges.
What you should do instead is the direct opposite. You have to start looking for challenges, regularly. You have to start training your ability to persist like a muscle. The best way to do so is by starting small. Start with challenges that are just at the edge of your current level of experience, knowledge and skills.
So, assess your current skill level. Then, take on challenges that are difficult for you, but still possible to solve. If it is too easy or boring it will not work. You may learn something, but it will not be a lot. You have to be willing to go to the edge. You have to be willing to stretch your skills and struggle.
When you start with this, the first few months will be the most difficult. Don’t worry. This is normal. I can tell you from experience that, with time and practice, it will get better. The hard work you put into this practice matters. As time goes by your persistence will strengthen and your ability to think like a programmer will improve.
Commit to finishing what you start
One good practice for strengthening your ability to persist is committing to finish what you start. When you begin a large project commit to finishing it and prepare for hours of hard work. In addition, as you work on your project, make it a practice to painstakingly examine every dash and apostrophe as you write your code.
This will help you get better in spotting things that can lead to bugs. It can save you hours spent on debugging. It will also help you develop your own coding style. However, the most important is that it will force you to focus on the code you are writing. Remember that being an expert is also about the quality of the results you produce, your code.
As we discussed, almost nothing works at the first try. You have to try again and again. Sometimes, you might even have to start multiple times from scratch. This is painful, but necessary, part of the process. It is also reason why developing patience is so important in order to learn how to think like a programmer.
Programmers engage in time-intensive work. If you want to learn to think like a programmer you have to learn to control yourself. Avoid losing your patience or giving up in despair. Start working on cultivating your patience. This will help you keep going when times get tough. It will also help you avoid sloppy programming.
Yes, brute force usually works. However, it works even better when you are still able to think rationally and clearly. So, when you’re really getting frustrated with the problem you are wrestling with, or some other activity, take a break, at least a small one. For example, get up and take a walk and get some fresh air.
Getting some fresh air or even briefly changing your environment can help you refresh your mind and approach your task with renewed energy. This is something many programmers and other creative people will confirm. In some cases, you may experience eureka moment during that short break, i.e. you may solve that problem.
So, when you feel you are not getting anywhere and you can no longer think clearly, don’t force it. Take a short break. Putting that problem to rest just for couple of minutes is enough to give your brain and body some time to refresh. Then, you can get back to your problem and start again with fresh and relaxed mind.
Understand the problem
Understand the problem first is another thing to learn if you want to learn to think like a programmer. Before you start solving any problem, take a moment to think about it and really understand it. It is often true that many hard problems are hard because you don’t understand them. When you take the time to understand them they will become easier.
So, when you encounter a problem, resist the temptation to immediately solving it. Instead, think about it and make sure you understand it. How to know when you understand a problem? You are likely to understand the problem when you can explain it in plain English. If you can’t do that, there is still something missing, something you don’t understand.
Explaining the problem is often better than hours of coding
Almost everyone probably experienced this once or twice. You are stuck on a problem and it seems you just can’t figure out how to solve it. Then, someone comes and asks you about. You start explaining it, and as you talk, you suddenly start to understand the underlying logic and also how to solve it.
The majority of experienced programmers know this feeling. This is also why they often write down their problem, draw a diagram, or just tell someone else about it. They know that just by doing this they can really get to the roots of that problem, to really understand it. Then, they have much better chance to solve it.
So, if you want to learn to think like a programmer adopt this habit. Spend some time thinking about the problem you want to solve before you start solving it. Do this before you write a single line of code. Describe it in detail on the paper, or computer, draw a diagram or explain it to someone.
Feel free to choose any approach you like. Just make sure you understand it. Remember you understand the problem when you can explain it in plain English. Don’t try to solve the problem until you can explain it in plain English. You would only waste your time. Remember, to think like a programmer you have to start with thinking.
Break it down into smaller parts
Have you ever tried tackle complex problem as a whole? Then, you probably know this approach doesn’t work well. It often leads to getting stuck. Every experienced programmer will agree with this observation. It is also why experienced programmers never try to solve any problem as a whole, or in one big chunk.
What experienced programmers do is they think in chunks. This is how you have to start to think in order to think like a programmer. For example, instead of seeing one big and complex project, or long piece of code, divide it into smaller sections, and subsections. This is the best way to start solving any problem.
It is also important to think like a programmer. Find a way to split your problem, challenge, project and tasks into small chunks. Then, create a step-by-step process to complete each element of the project. Don’t try to complete all of them at once. Take them one at the time and focus solely on the task, or chunk, at hand.
Start as soon as possible
There is a time to think and then there is a time to write code, a lot of code. Some programmers, especially beginners hesitate to start. Reason? They are afraid they don’t know how to solve it. They don’t have complete and perfect plan to get that thing from start to finish. Experienced programmers don’t do that.
Yes, experienced programmers take time to understand the problem. Then, they take time to think about possible approaches to solve it. However, that is about it. They jump right into a given programming task and start trying different ideas to see which works. Then, when they find it, they clean up their work. Until then, they don’t mind being messy.
To think like a programmer learn to think and solve problems as you go. If you’re not entirely sure how to tackle the problem standing in front of you, that’s okay. You don’t have to know. You don’t have to have precise plan that will take you from the start to the finish. You don’t have to have any plan at all.
The only thing you have to do is just start. Find the smallest or easiest task you know to do and start with it. You will figure out the later as you go. Remember, to think like a programmer, one must avoid any hesitations and doubts and get to work. Programming is a creative task and creativity works best when you get moment. So, start coding.
Review and reflect on your work and learn from it
To think like a programmer also means double-checking results of your work. When you complete something, a task or project, double-check your code for errors, typos and other mistakes. Then, run run tests, or run your code through a debugger. If you find any pitfall, re-read your code line by line, scanning for errors until you find what the problem is.
Like with many things it is not about the quantity of your work, but also about the quality. If you want to become a really good programmer, even expert, you can’t tolerate sloppy code. It is okay to be messy as you try different ideas to solve the problem at hand. When you solve it, clean that mess. Check for errors and typos and format your code.
As you double-check your code, you may find space for improvement. You may find ways to optimize some parts of your code, make it more effective and efficient. In other words, you can learn useful things you can use in your future projects. Also, this double-checking can help you find places where you are more likely to make mistakes, or repeat them.
You can then use this information in two ways. First, in your future project, when you get to one of those specific points when you are likely to make mistakes, you will know you have to pay extra attention so you can avoid making them. Second, you can work on those mistakes. When you know what mistakes you are making it is much easier to fix them.
So, when you finish a project or task, don’t rush and start another one. Instead, thinking about the work you’ve just finished. Review your code and your experience. Your past experience is often the most valuable source of learning. So, reflect on it. Learn from it. Reflect on what you learned and what you struggled with.
Then, look for opportunities to apply what you’ve learned. Use these lessons to improve your ability to plan projects and tasks, to break them down into smaller parts. Use them to better estimate the time to completion. Take the solutions you discovered in one challenge and use them in others. Use your past experience to guide your future work.
Epilogue: How to think like a programmer
Now you know the first six tips that will help you learn to think like a programmer. These tips were, first, being persistent. When you encounter difficult problem reject giving up. Instead, keep trying until you solve it. Second, being patient. Programming is about solving problems. This requires time, sometimes a lot of time.
So, be patient and be willing to give as much time as necessary.
Third, get to roots of the problem and really understand it before you attempt to solve it. You understand it when you can describe it and explain it in plain English. Understanding a problem is often better and more effective than hours of coding.
Fourth, break it down into smaller parts. Don’t try to solve complex problems as one big thing. Instead, divide it into smaller and more manageable parts and deal with each, one at the time. Fifth, start as soon as possible. There is a time for learning about the problem. There is also time to think about potential solutions.
However, the most important thing is getting started. Remember, to think like a programmer, you have to learn to solve problems as you go. So, don’t wait for perfect plan or solution. Do your thinking and then find the smallest task you can start with and start coding. Remember, you will figure out the rest as you go.
Sixth, review and reflect on your work and learn from it. When you finish a project or task, don’t rush and start another one. Instead, review your code and your experience. Reflect on it. Learn from it. Then, look for opportunities to apply what you’ve learned. Remember, use your past experience to guide your future work.
If you liked this article, please subscribe so you don't miss any future post.