It's no surprise that learning to code is extremely difficult at times. Similar to learning a new speaking language, you have to understand a whole new syntax, flow of the language, and how it's best used. Additionally, if it's your first programming language, it's even more confusing!
As I have ventured through my journey I have encountered three "must have" components, to problem solving and "thinking in code":
- Understanding what the problem is asking
- Comprehending how to implement those core principles
If this is your first coding language, I know it is intimidating! Truth be told, I'm still intimidated from time-to-time! I've composed three basic, yet essential, tips that I find are great for learning this new way of thinking!
When I say this - I mean it! Diligence, hard work, and constant studying are key. Anything in the programming world is always in flux. Syntax changes, new libraries are introduced, things are revolutionized so frequently, that you won't really know everything... ever!
Let me say this:
You don't know, what you don't know!
Wait... so you want me to:
- Compare that to the money in my drawer
- Decide if I have enough money to produce change for your item
- Actually, manipulate those values in my drawer appropriately by how much cash was received
- Then, return the amount of cash left in the drawer?
Something of the sort seemed genuinely impossible! Wizardry! Voodoo Magic! How was I supposed to do all of this with just simple array methods, when all I learned was how to
.pop(); something off of an array?!
The best way to relate this to something not coding related would be something like cooking. When you've never cooked a single dish in your life, you have to read recipes. Digest that new way of thinking! What needs salt? Does this need sugar?
If you've never cooked in your life, how are you supposed to know that chocolate doesn't go inside of your bean chili?
... okay, maybe that's an extreme example, but you understand my point!
It's part of the learning process!
While yes, studying is definitely key to learning something new, oftentimes in a situation like this, seeing how it's implemented is a tad bit confusing. This brings me to my next point...
There is an enormous amount of value in watching someone else solve problems, and plenty of ways to do so!
- Read forums
- Talk to other people are similar learning stages
- Look at the variety of solutions to code challenges
I neglected this aspect for a while, because I wanted the pride of solving a challenge on my own. What I had learned though, was that in the beginning, most people can not. It's not that you are terrible, or will never understand, but it's an entirely new way of thinking, you can't expect yourself to become a coding master within the first 60 days!
When I started reading other individual's solutions to coding challenges, my mind began blossoming with ideas on how to solve old problems I struggled immensely with!
Back to my cooking analogy - you may create a habit of cooking a stew, or baking a cake a certain type of way.. yet, how will you ever know the alternative? What if someone else's cake is always higher quality?
This is when you learn from those other people! Watch their style, the technique, the finesse, if you will! Definitely don't copy their style, but learn from it! Take bits and pieces, and make it your own. This is a great way to learn!
To segue into the tip that ties everything together..
Learning to code is emotionally draining. When you are first struggling through those initial problems, it is extremely unmotivating. It's easy to just wish that the skills will seep their way into your brain... and they will.. if you practice!
None of the other tips will be of value if you don't put in effort. You are going to break code, your solution will be completely backwards. You are going to fail!
However, isn't that the case with any new skill?
Returning to my kitchen analogy, have you really learned how to bake, if you've never burned a cake? As someone who has spent a ton of time working in restaurants, I can confidently say I learned the most when I destroyed things!
Overcooking pastas, totally scorching pizzas, dropping steaks on the floor, forgetting you have something in the oven - these mistakes are what help you learn!
This is the same way with code! Mistakes are your friend, and there is a lot to learn from them. I can confidently say that even if you spent hours trying to solve a problem, and it turns out to be wrong - you still learned a lot from those hours!
Countless times I have invested my day into solving a problem, just to discover I was attempting to solve it in the entirely wrong way! However, during that time, I picked up some new methods, implemented some new code, and pushed my boundaries.
My point? Similar to any skill - failure is part of the routine. Strive to fail! There is a lot to learn from broken code - trust me!
In short, learning to think in code is a process. You need to expose yourself to the benefits of your language, whether that's loops, array, objects, classes, or something else! Watch other's on how they implement these skills, and create your own flow. I've found inspiration from many other people, but ultimately created my own problem-solving style.
Finally, the most important of them all: fail.
When I wasn't failing, I definitely was learning. It's comforting to stick with the easy problems, and write a function that adds two numbers all day, but that's not when you learn. You learn when you really stretch yourself. Mess up, fail, and then try again!