Best practices for learning how to code
So, you’ve finished your first introductory coding course, but you don’t know what to do next. We’ve created this article to give you tips on what you should do, and what you shouldn’t do when you’re taking your first steps as a developer and trying to build strong coding skills.
Although this was originally designed for applicants preparing for the Code Chrysalis Immersive technical interview, it has useful information for anyone looking to take their next steps as a new developer!
Let’s get right into it. Here’s some advice to help you take your skills to the next level.
Tip 1: Be careful about coding challenge websites
Ignore the top scorers…for now. Oftentimes, the code solutions that get the top scores on websites like CodeWars and Coderbyte are not examples of good code. This is because the websites are games, and part of the game for developers is to see how short they can get their solutions.
While these solutions work, they are not necessarily what would be recommended in a professional setting. Why? That leads us to our next piece of advice.
Tip 2: Write code for people
We write code for people, and it is run by computers. Not the other way around. Short code does not always mean clear code.
If you take the code from coding challenge sites, you run the risk of interacting without fully understanding the code in question. If you’re new to coding, these often involve techniques or concepts that are a few levels above what you should be focusing on.
Comprehension is key.
Tip 3: Passing tests are useless if you do not know why
It can be easy to throw a bunch of ideas against a wall and see what sticks. But it would be even better if you knew why it sticks. For beginners and experienced devs alike, it is key to also understand the why’s.
If you do not understand “why” for basic topics, how will you understand “why” for advanced topics?
Tip 4: Be careful of copy-pasting code from StackOverflow or blogs
Make sure you know why something works (or does not work). Invest the time to understand the fundamentals. Another problem with StackOverflow – or blogs – is that they can be wrong, whether intentional or not. They can also be outdated.
Stay vigilant about the material or answers you are looking at.
Tip 5: Familiarize yourself with reading documentation
Reading documentation (on-line manuals) is an important skill. Frankly, it is a skill that many working developers lack, so building up this skill early will set you apart.
You can find JavaScript documentation on the Mozilla Developer Network. It can be intimidating to read and you will not be able to understand everything you read for quite a while. But that’s ok.
If you can learn just one new thing every time you try to read the documentation, you are making solid progress.
Tip 6: Learn to do things without native methods first
If you are using .forEach and .map for everything, I suggest you try solving problems without using any of those.
We want to be able to understand how these built-in methods work before using them. If you do not know how to do things without them, you will always be coding half-blind.
Make sure you have 20/20 vision. Your career will thank you for it.
Tip 7: Check your assumptions by running and checking your code often
Do not be afraid to use console.log to print things out.
Always double check.
Be aware of what data you have access to at any given point in your code.
Make sure that you test your assumptions — are you sure that variable is a function? A string? A number?
Sometimes, what you think is a 2 is instead a ‘2’ and that can make a big difference in code. Use console.log and also typeof to double-check that what you think is true.
This will also protect you from bugs. It can be frustrating to write a bunch of code, only to run it at the end and realize that there is something wrong. Protect yourself from making these mistakes before you reach the end.
Tip 8: Error messages are your friends
When you see an error message appear, this is actually something to welcome.
Familiarize yourself with common error messages and what they mean — do not ignore them. Learn to read them so you can use them to your advantage.
Error messages will also give you a line number in your code where the error originated from. If it isn’t immediately clear what the error message means, Google it!
As you get more advanced, you will come across silent errors. The evil twin of error messages. These are situations where something is not working, but you do not have a handy error message telling you where it is going wrong. They are the worst.
So, next time you see an error message pop up, give them a big hug and thank you. And then listen to them.
We’ve listed some common error messages for beginner coders below:
Uncaught ReferenceError: ______is not defined> |
This usually happens because a variable or function name is missing; the JavaScript engine is not sure what you are referring to.
Are you sure you spelled everything correctly? Are all of your variables declared? Did you copy/paste code? (Please don’t copy-paste code without understanding it)
Uncaught SyntaxError: Function statements require a function name Uncaught SyntaxError: Unexpected identifier. |
Did you forget a closing or opening bracket or parenthesis? That is usually the case.
Uncaught TypeError: Cannot read property> |
This often happens when you are trying to read a property or call a method on an undefined object. Are you using a method that does not exist on an object? Is your object defined?
For more information, check out this helpful article.
Tip 9: Go slow and review often
It feels a little counter-intuitive, right?
Review concepts that you think you are already familiar with often. You will probably always come across something new. Try seeing if you can understand more MDN documentation each time.
You are learning the fundamental building blocks that will support your career. Spend time making sure this foundation is as strong as possible. Do not be ashamed of going back to review strings and numbers, even if you think you already know how to use them. There is always more to learn before you build strong coding skills.
So while React can seem really attractive, if you do not have a good grasp of the basics, it will be a struggle and waste of effort.
Tip 10: Make it work, then make it pretty
Do not stress about making your code look elegant. First, get it working. Then, we can go back and clean it up.
Working and ugly is better than broken and…still broken!
About the author:
===
Yan Fan is Code Chrysalis’ CTO and Co-Founder. Born in China and raised in Seattle, she graduated from Dartmouth College with degrees in Economics and Arabic. After graduation, Yan worked at Bunge Global Agribusiness, a commodities trading house. After a career change into tech, Yan worked as a software engineer at Ayasdi, a leading Silicon Valley machine learning startup, and as an instructor for Hack Reactor’s prep course.
Code Chrysalis is Yan’s second coding bootcamp–with Hack Reactor, she co-founded and served as CTO of a coding school in Jordan helping refugees in 2016.