How to think like a programmer
First, let’s understand what programming is. Programming is a set of instructions telling the computer exactly what to do – straightforward.
However, programming is more than that. In the real world, programming is a tool to give solutions.
Instead of thinking about programming in a way that we need to code something up and it’s done. We need to think more about creating solutions to problems with programming. Programming is a toolset, and when we have a project to do, we need to ask out self:
- What problem am I trying to solve?
- What else besides writing code can be done?
- What can I do to make these problems easier to solve with the code?
For example, a business needs to filter the columns in a specific way on excel, it takes them 5hours to do it each day, and they have specific people to sort the information.
With programming, we can solve their problem by automating the task and tell the program how to sort the information that is being entered automatically. That is a solution to a problem with programming.
Programming is nothing more than a set of tools to achieve the outcome we need and help the customer – be it a doctor, a business or an individual.
That’s another topic for itself, so let’s see on how we can actually think like a programmer, and create something awesome.
When thinking about programming, we think about it as a hard thing to do. In fact, programming might be hard, depending on what we are doing.
If we need to solve an easy thing, programming will be… easy.
However, if we need to solve a complex thing, programming get’s more complex.
There is no such a thing like “programming is: easy/hard” – it depends on the complexity of the problem we are trying to solve.
Is cooking easy? Cooking is easy! Phew! But is it really? – it depends on what we are trying to cook.
Cooking eggs on oil is straightforward. Anyone can do it. Preparing a master chef dish? Well, you might need to learn how to prepare the food, exactly know how much to put what, learn few concepts on how to do the dish, and at the end, know how to put it on the plate.
It’s still cooking, but is cooking easy? Same with programming, it depends on the problem that you are trying to solve.
Programming is all about problem-solving. It’s not about if you know the language syntax, remember how to write a loop, knowing a framework/libraries such as React, Angular, Twitter Bootstrap or perhaps knowing a Language.
It’s a mentality you need to develop on how to tackle challenges and move forward – it’s about how you deal with problems ( it can be applied in your real life scenarios as well ).
Said that you still need to learn programming concepts to be effective at it, and know how to tackle more complex problems, as it does require logic to do it.
Junior Dev VS. Senior Dev
Yes, a Senior Developer knows programming concepts and know how the language works, but that comes from building real-life features/websites/software, and experiencing what and how to do it – it’s part of the process by figuring out things on how to do them. The more experience you have, the easier it will become for you to take other challenges and figure them out.
The difference between Junior and a Senior developer, apart from the experience and higher, is how they deal with the problems. A Senior programmer will be able to solve a problem in a language he has never touched or seen, while you might be struggling with it for weeks.
Don’t be put if you don’t remember the syntax. At times, I (and other developers) don’t remember some HTML! Gladly we know how to google, and we can figure it out in 2seconds.
How can you solve a challenge? The best way is to use google and a system, a way of thinking. A step-by-step process that allows you to tackle the challenges.
How do we go on about it? Keep reading!
Thinking like a programmer
“I don’t know this programming language and I’m not yet a programmer, but I want to become one, however, I can’t build anything from scratch” – does that sounds familiar?
You stare at the blank page, without knowing how to begin. You’re afraid that you will get an error that you don’t know how to solve. You’re not sure how it should work in the first place.
Let’s see how we can solve a coding problem.
But before we start thinking about how we can code up something, we need to have a *system* in place, on how we are going to tackle the challenge – this applies to everything that we do, either in coding or real-life scenario (successful people have systems in place and they know exactly how they are going to achieve their goals).
I’d applied this mindset to programming, and I have improved instantly! I became much better at starting from a blank page and to know how to tackle the challenges that I didn’t plan for, or that just came up.
This will help you in bug solving, in creating scripts, and it can help you even in your day to day life.
The best way to go about problems is having a system in place. You can follow these 5 steps:
- Understand the problem
- Plan and break down it into smaller problems
- Find solutions o your smaller problems
- Assemble the solution in a coherent manner
- Refactor and practice
Step 1: Understand the problem
Understand the problem. Most problems are hard because you don’t understand what is being asked.
When thinking about the problem we need to solve, you need to know exactly how it needs to behave, and what it is their function.
The next step would be to plan it and break it into small pieces.
Step 2: Plan and break down into smaller problems
Before writing any code, you should always plan and think on how something should be done – it will save you time in the long term and it will make it easier for you to figure out on how to do it. You’ll also know what has to be done to make the script work.
How do you cook a cake?
Here is what most people would answer:
- Get a pan
- Mix the ingredients
- Take out and eat
However, if you think logically about the question, you will see that there are plenty of steps missing.
- What cake do we want to bake?
- What ingredients do we need for the cake?
- What pan should we take?
- How hot should the oven be?
- How long should the cake be baked for?
- How long should we wait before eating the cake?
When we solve a coding challenge, you need to think about every step that you can come up at the time (it’s okay to not know every step, and come back later to add a step that you didn’t think ok before), and break the problem into smaller pieces.
Step 3: Find solutions to your smaller problems
Here you need to find a solution to your smaller problems. It’s important to be as detailed as possible. Remember that the computer needs steps for every single move it makes.
- What cake? – Chocolate cake with bananas
- What ingredients do we need? – Chocolate, bananas, flour, eggs
- What pan should we take? – The one that’s made for the oven
- How hot should the oven be? – 350 degrees F
- How long should we bake the cake? – 40minutes
- How long should we wait before eating the cake? – put in the fridge for 8hours and then it’s ready to eat
- Use your hands to eat, fork or a spoon – don’t forget about the plate and enjoy!
Sometimes you need to get even deeper into the answer, like the number 2 and 3.
- Where do we get the ingredients? – We walk to a local shop 15minutes away.
- How much do we need of each ingredient? – 500g of Chocolate, 4bananas, 3cups of flour, 2eggs and pour on the pan
- Where do you get the pan from? – We buy it from a shop that sells pans for baking, 30minutes away.
Now that you have pieces for your smaller problems, you can connect them together like a puzzle, to get the big picture of it, and make the script work.
Step 4: Assemble the solution in a coherent manner
So, to cook the cake we need to:
- Go to a local shop 30minutes away and buy a baking pan
- Go to a local shop 15minutes away and buy the ingredients
- Mix 500g of Chocolate, 4bananas, 3cups of flour, 2eggs and pour on the pan
- Pre-heat the oven to 350 degrees F
- Bake for 40minutes
- Put the cake in the fridge for 8hours before eating
- Use your hands, fork or a spoon to eat the cake, and have a plate.
- For the maximum enjoyment don’t rush eating the cake.
Cake ready to eat!
Step 5: Refactor and practice
Psychologist many time listen to your problems, and you might point out to the holes in your logic before.
Ever had a moment where you’re asking advice, someone, explaining to them the problem, and meanwhile, you are figuring it out as the way you talk to the person? At the time you finish explaining to him the problem, you have already found the solution.
I had that happen to me plenty of times. Asked a more advanced developer about a problem, and as I was talking or writing about it, I have figured it out before he spoke.
Ask questions but don’t overdo it!
For the first few months, I haven’t learned anything when I used forums and other developers to help me figure out the problem and get to the solution. I would ask about every single step on different forums and developers on how to achieve the result that I wanted.
By the time I had the solution, the code has passed via a dozen forum and a dozen more od developers that helped me to solve it – I didn’t learn anything.
I decided to ask fewer questions and be more independent, get off frameworks such as Twitter Bootstrap, jQuery and whatever you might think off – it has helped me a lot!
I have understood how to better think like a programmer, how I can tackle the challenges and solve them, and what most important, it gave me the opportunity to get my hands dirty and try to solve the actual challenge.
Now, it’s important to ask questions and look for help, just so you don’t waste too much time (at the end, figuring out a challenge, it’s not wasting time, but gaining more knowledge and experience, so don’t be worried about that – if it takes too long, then make sure you definitely ask for help ASAP).
There is no one program that can do everything – that’s why we work in a team.
There is a difference when working with a team, and when working on your self
Asking too early is bad as you miss the opportunity to learn on how to tackle the challenger, it’s good to struggle. That way you exercise your problem-solving skills, and when you figure something out on your own, it will stick for good.
There is a magnificent quote from Albert Einstein that says:
“It’s not that I’m so smart, it’s just that I stay with problems longer”
And once I have installed that mindset, once I stayed with problems longer, I could figure them out. It’s not that I couldn’t figure a problem out because I didn’t know how to do it, and I had to ask a more experienced developer, but because I tried one time and though I can’t do it so I left it, and someone else did thinking for me.
Now that I challenge my problems and stay with them longer, I have acquired more experience on how to think like a programmer.
Challenges to solve!
At first, it might seem extremely difficult, but the hardest challenge, will become a lot easier, than the first “easy” challenge, and that’s’ because you have acquired experience and learned how to think, improved you solving
- A modal
- A carousel/slider
- A pop-up
- A tab feature
- Navigation spy
- A robust clock
- Off-canvas navigation
And many more.
There are plenty of little challenges that you can practice by doing now.
Just remember, that like there is no magical pill to make your body slim and muscular in a day, as there is no magical pill to make you think like a pro programmer in a day.
Improvements over time
Remember that Rome wasn’t built in a day, a great athletic body wasn’t built in a day – no great thing was build in a day – and it wasn’t perfect either.
It was built over a period of time, with small improvements.
You need to practice to get better. Don’t be put off if you can’t create a component, or you can create only a small portion of it.
You need to practice, practice, and practice.
What does practice do?
Hell no, delete that word from your dictionary, there is no such thing as perfect – it will save you a bunch of time.
Practice makes small improvements over time – that’s it.
However, there is a word that’s close (or far) from perfection, which is “industry standards” – but that simply means that the code is well designed and it meets certain criteria such as optimized speed, maintainable and it’s well refactored, and many more.
Now that you know what to expect, and you have some ideas for the challenges, take action and start doing it!
Use codepen for a fast start!
See, that wasn’t that hard!
And if you think it’s still hard and you can’t do it, then you need to start thinking on how you can do it – you see, when you say you can’t do something, your brains stop working which will make it harder to achieve what you want.
The key here is to know how to tackle the challenges and break them down.
Once you have broken them into smaller challenges, find solutions to them, and once you did that, find solutions to the problems that you didn’t think about.
At the end of small problems, once you combine them all together, you will have the answer to your large problem.
Remember to share the awesome components you have built below in the comment section!
I wish you many challenges to come!