Top 10 coding tips for beginners

in #blog5 years ago (edited)


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

if(){}else{}

3.4.2- Loops

while(){}
for (){}
do{}while();

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.

indentação-01-01.jpg

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.

Why?

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.

Conclusion

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!

Until next time!



Posted from Creator's Keep | https://creatorskeep.com/top-10-coding-tips-for-beginners/
Sort:  

Nice1. I would add something very important - use GitHub. This really makes job easier and allows to track the changes, issues and history of software.
GitHub will be also helpful in terns of getting new position as recruiters will be able to see that you are actively coding

Indeed! GitHub is quite useful as well.
Thank you very much for your input!

Excellent post!

I'd add: think about the problems you are trying to find solutions for, and then get a basic grasp of the different paradigms: functional vs oop, client vs server-side, etc.

True, designing solutions for problems is at the core of coding, and starting with that mindset is quite important.
Thank you very much for your contribution!

My pleasure. I'm glad I found this great community. Look forward to contributing to its awesomeness.

@shaden, very well articulated post!

For the last 15-20 years I've been an economist. But I've decided to change my profession. That's why I've just started to learn how to write code and have chosen to start with JavaScript.

I find your post very useful! Thank you so much for putting efforts to write it!

Posted using Partiko Android

Greetings @cryptospa!

First of all, that's awesome! It takes quite the determination to change your profession after so many years.

Regarding learning JavaScript as your first language, go for it! I am mostly a web dev so I absolutely love it!

But be careful about one thing: usually variables have a type. On languages like Java and C++, you have to declare a variable like "int n=0" in order to declare that "n" will be a number.

On JavaScript this does not happen as you declare a variable as var and it's type varies depending on what you put inside of it.

So be careful in the future regarding this aspect.

Thank you very much for your feedback and good luck on your endeavours!

It's a good article, well layed out. I've often though about starting to learn but wouldn't even know where to start. It all above my head.

Hi @niallon11 and thank you very much for your feedback.

Regarding your troubles to start coding, I would do something like this: what do I want to do? Web Development? Desktop Apps? Mobile Apps?

Pick one thing and focus on it.

If you want to do desktop or mobile apps, learning Java is a great start. For web development, you can go for HTML+ CSS and Javascript.

Follow some simple tutorials regarding the language of your choosing just for you to watch things working and get some enthusiasm. Then focus on trying to understand the logical structure of the code you followed.

The New Boston's youtube channel is a great source of coding tutorials, I highly advise you to check it out. Also, you might want to check Dev Ed's youtube channel as he got some good stuff as well.

The following step would be learning pseudocode as it would allow you to solidify your coder's logic.

Also, you might want to check my article regarding the creation of cool projects as it might help you have another perspective on this subject.

I hope this helps you! Keep it up!

I've just started to learn JavaScript. I am a Beginner. Starting from a scratch. So, give it a try, @niallon11.

Posted using Partiko Android

Where are you starting with it? Is there a good course or program to teach the basics.

I live in Bulgaria. There is an institute called SoftUni that conducts different courses (online) in Bulgarian Language. I will start my first course "Programing Basics with JavaScript" in October. The course is 2 months long. Then there will be an exam. If i pass the exam I can start my education there (online): 3 modules about JavaScript. Each module is 4 months long with exam at the end. If I pass all exams with good grades they will find a job for me. Some of my friends have already changed their profession: they went through that institute, graduated within 1-1,5 years and started a job in the IT sphere. So, they recommended to me to go to this institute SoftUni.

I have downloaded the textbook for my first course (that will start in October) and I've started to read it. It is 410 pages, with 10 lessons with many excercises. In addition there is a video to each of the lessons. So, I will try to read the textbook, watch the video lessons and do the exercises, before my course starts in October.

I think there should be such kind of courses/education in the place you live. As I see you live in Ireland.

That sounds like a great opportunity. I tend to have spare time in the wintertime so might look into something similar to keep me busy. Even something basic to get me started. I'm sure youtube has tutorials to follow and see if i like it or not before going further.

Yeah, definitely, you can find some tutorials on YouTube. So, good luck!

Posted using Partiko Android

@shaden I´ve just started learning Python, and love it! I would highly recommend it for anyone interested in learning a computer language.
I´m doing my course through Coursera.
If anyone wants me to print("hello world") for them I`m available for hire ;-)

Hi @bistonic,
That's awesome!
Learning through a course is always a good idea because it allows you to learn in a structured way.
Keep it up!

Thanks for the encouragement.
I "learnt" HTML/CSS the unstructured way, but it`s not the same as actually learning/studying something from a scratch and following course work and being tested on your knowledge. I am following a more disciplined approach this time around with Python :-)

Hello!

This post has been manually curated, resteemed
and gifted with some virtually delicious cake
from the @helpiecake curation team!

Much love to you from all of us at @helpie!
Keep up the great work!


helpiecake

Manually curated by @niallon11.


@helpie is a Community Witness.
For more information about our project,
please visit this month’s UPDATE post.

This post had received 5.00% upvote from @steemitportugal account!
Our website has lots of news and tutorials you can visit right now at www.steemitportugal.com

Click here to vote
steemitportugal
Delegation for daily voting: 10SP-25SP-50SP-100SP-250SP-500SP-1000SP

Hello @shaden, thank you for sharing this creative work! We just stopped by to say that you've been upvoted by the @creativecrypto magazine. The Creative Crypto is all about art on the blockchain and learning from creatives like you. Looking forward to crossing paths again soon. Steem on!

Congratulations @shaden! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You received more than 2000 upvotes. Your next target is to reach 3000 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Vote for @Steemitboard as a witness to get one more award and increased upvotes!