Useful Tips for writing better code and increasing productivity
I entered the world of programming back in 2011. I had no formal education in programming, I just brought a book and started learning.Today when I look at my journey I realize it I made a lot of mistakes while learning programming and it's not possible to avoid all of them and according to me you should not avoid some of the mistakes that I am made, as these mistakes teach you a lot about programming but there are some mistakes that you should avoid no matter if you are a beginner or an intermediate or an expert. I am about to share some tips with you , you may have heard many of these earlier from other people or if you are studying in some school or university from your teachers or may be you never thought about these.
Variable Confusion
Tip #1
While writing your code please make sure that the variables are defined in a manner that even after 6 months when you read it you can distinguish between global and local variables. Also please do not give the same name to two variables.Tip #2
You should give some meaningful names to your variables. Please avoid giving names like X and Y and Z A B C or something like that. A program with more understandable variable names is considered good.For example if you are writing a function for summation of two numbers, is use variables like num1 and num2 and sum.
Tip #3
One more thing I would like to tell you is that you should use underscores between a long variable names.For example, instead of writing this,
char [50] cityname;
You should write,
char [50] city_name;
In a big program it looks great if the variable names are easier to read an maintain if you follow above tips....
Know It....Before Coding It
OK now this is something that every newbie does.If you don't know what the problem is you cannot solve it.Take time to understand things before just doing them.
Don't give a lot time to solve a problem,Generally 5 minutes of brainstorming will be fine to solve a problem but if takes more than that you should look up for it,a google search will be fine.
In my opinion you should always have a reference book or something similar with you while coding.
Also, a cheat sheet about everything that you do must be with you.
As Einstein said..."You cannot solve a problem at the same level of consciousness where it originated" you should try different ways to think about a problem. A different approach will work great.
Tip #4
Don't give a lot time to solve a problem,Generally 5 minutes of brainstorming will be fine to solve a problem but if takes more than that you should look up for it,a google search will be fine.
In my opinion you should always have a reference book or something similar with you while coding.
Also, a cheat sheet about everything that you do must be with you.
Tip#5
As Einstein said..."You cannot solve a problem at the same level of consciousness where it originated" you should try different ways to think about a problem. A different approach will work great.
Don't Make it too big
Who likes to read a lot text....well some people does, but one thing for sure no one likes to read long text of code. Its always a good idea to break your code into smaller parts.
Double check your algorithms for making it efficient.Again if your code is taking more time for doing tasks in runtime, its not good.
Tip#6
Breaking your code into smaller parts is a good idea but its not the key. The key is to make it more human readable but also efficient. Make sure that code is well documented. A confusing code will take more of time precious time.Double check your algorithms for making it efficient.Again if your code is taking more time for doing tasks in runtime, its not good.
Some Other Tips
1.) Time is the Key: Time management is important no matter what you do and how you do.
2.) Its not about fast or slow its about efficiency: don't put a lot of effort for doing it fast its about about doing it right not fast.
3.)Read more books to gain more knowledge: Read often updated books for learning about new technologies
4.) Listen to others : listen to you teammates, know their opinion and respect it.
5.) Learning is a never stopping process: Don't think you have mastered everything.
Tell in the comments if I missed something or give your opinion on these tips.
You should see my other posts about html and JavaScript. These light weight post will give idea about JavaScript and html 5.
Thanks for reading........
Comments
Post a Comment