Are you a new coder or thinking about getting your feet on the world of coding? Then buckle up! It will be a wonderful ride with many obstacles to surpass and many goals to accomplish.
I’ve been a coder for more than 10 years now, and today I would like to share with you some tips and advices that I wish I knew when I started my journey as a coder.
1- Train the coder’s mindset
Coding is just the act of transfering your reasoning into a logical structure.
And you know what?
You already have experience on that!
Writing is the act of using your logic and apply it on a formal structure. In this case, the alphabet.
The same principle also applies on coding.
You just have to learn how to think as a coder and apply that way of thinking on a language, which is just a logical structure with syntax and other particularities.
And you know what?
The coder’s logic is the same across most of the languages out there!
So my advice to you is to REALLY understand the coder’s logic, because after that, you can learn any language quite easily.
To do this, start by writing pseudocode on paper to grasp the coder’s logic.
2- Practice, Practice, and then Practice some more!
The best way to learn coding is to code!
There is no way around this. You have to write a lot of code in order to learn. And you will fail a lot, it’s normal, but you will learn with your mistakes.
Failing constantly might demotivate you, so what I advise you to do is to think on a simple project that you would like to do and do it! Keep the project tangible and simple. Then if you want, you can iterate on it.
Believe me, being able to complete one project by yourself, even if it is a simple calculator, is really satisfying!
By the way, if you want to know more about creating your cool projects, you might want to check this article.
3- Organize your code!
Keeping your code organized and clean is a really important task as a coder. Trust me, you don’t want to have a complex program all messy at your hands.
You will have difficulties finding what you are looking for, and if you are working on a project together with a team, problems can escalate quickly.
So here are some tips for you to keep your code clean and beautiful.
3.1- Names matter!
It is considered as a good programming norm, the use of small letters at the beginning of the variable name (for example: int var1 ) and large letter at the beginning of the class name (for example: public class Numbers).
Also, if you want to create a variable with more than one name, be sure to merge them together so that the first name is lowercase and the rest have a capital letter (for example: checkTimeInSeconds) aka lower camel case.
You can also use underscore to separate names, but I still advise the first option.
3.2- Global Variables
When you have to declare global variables, be sure to do so in the same area of the script. This way, you’ll be able to easily find the variables you want to find since you have an idea of where they might be declared.
Personally, I prefer to place them at the beginning of each script.
3.3- Comment your code
Commenting your code regularly is a great practice since it allows you to document your work directly on your code. This is enables you to find what you are looking for in an easier manner, as well as helping your team picking up where you left off.
You can also use comments to “disable” code temporarily. This is great for debuging purposes and to perform any other action that requires you to keep some lines of code disabled on your script.
3.4- Be careful while writing logical structures
Have you ever heard stories like the following one?
My code didn’t work just because of a “;”
The problem here is not following the correct syntax that your code requires. It’s like writing a phrase without a “.” or a “!” or a question without a “?”.
So my tip is to write the full structure first before populating it. This way, you’ll be able to avoid many syntax errors that can appear in your way.
Here are some examples.
3.4.1- Conditional structures
Note: Depending on the language used, these structures can be diferent.
3.5- “Tab” your code
Keeping you code clean and readable is a great way for you as a coder to be more effective. For that, I advise you to Tab your code.
The main objective is to align code in blocks, to understand where a logical structure begins and ends. For example, if you have multiple nested if-statements, it’ll be easier to follow the code if it is tabbed.
Let me illustrate the idea on the image below.
4- Avoid code repetition
When you are learning to program, it’s easy to repeat code. It will just be unnecessary and will reduce your program’s performance.
To avoid these situations, use functions whenever possible.
These structures allow you to encapsulate blocks of code to perform certain actions and/or return results.
They also provide reusability and flexibility for different situations, so I highly advise you to learn these structures properly as they are fundamental to any programming language.
5- Debug your code often
Whenever you finish a feature, test it!
How? Breakdown the problem in multiple small parts!
Start by printing labeled instructions on the console through various parts of your code. If the print was successful, then the program didn’t crash there. If not, you’ll have a basis to start debugging.
Remember: it’s important for to test your code frequently. If you do, you’ll reduce the chance for you to be lost in a sea of errors.
6- Save your project frequently
As we saw in the last section, problems tend to arise when we least expect them, so save your project whenever you make any significant changes!
To do this, I advise you to check what is your IDE’s Hotkey that allows you to save your project. Do this often and you’ll find yourself saving unconsciously.
7- Pen and paper are your friends
Many coders take notes on paper. It is a great and flexible tool that allows you to solidify ideas, organize your logic and even explain your idea to someone else.
I strongly advise you to start using pen and paper on your projects as it will help you a lot.
If you want to know more about this topic, you can do so here.
8- Don’t give up
Coding is a skill that requires a lot of practice, so consistency is essencial.
Start slow but strong. Try to accomplish small goals every day, make your own little projects for the sake of learning, and you will eventually succeed!
9- Learn how to learn
If you are starting to code by yourself, or even if you have some kind of support, it’s essencial for you to learn how to learn.
Because on this field, you won’t stop learning. The world of programming is constantly updating itself on a rapid pace. And in order to keep up with these updates, you’ll need to learn new things.
10- Embrace failure
I’ll say this bluntly. You will fail, a lot. But you will also learn and improve with your mistakes.
This is the best way to grow as a coder.
Read what your error messages display and try to solve them. They are like your teachers. You can also try and provoke errors in order to understand how things work.
Coding can be hard at first glance, but there is nothing to be afraid of.
As we saw previously, it’s just a structured way to pour your logic into software and tell it what it needs to do. And all of it starts with the coder’s mindset.
In order for new coders to improve, we also saw that:
- Practicing a lot is the best way to learn coding;
- Organizing your code and keeping it clean will help you in the long term;
- Avoiding code repetition is really powerful;
- Debugging your code often and saving your project frequently will avoid some problems in the future;
- Writing your logic on paper will help you visualize your problems and solidify ideas and solutions;
- Consistency is essencial for learning coding, so don’t give up!
- It’s important to learn how to learn, because you will never stop learning new things;
- Embracing failure is a great way to learn faster by learning with your mistakes.
At what stage are you on learning code? Do you have more tips for new coders? Did you find this post helpful?
Let me know in the comments!