+ 1014

[NOTQUESTION] A Helpful Coding Tip

A lot of people know that it is a good practice to comment your code.But there is something else that is more helpful.In Zed Shaw's 'Learn python the hard way' book he advised to comment each line of a code you don't understand.By that I mean is if you don't understand a code, go through each line and explain what that line does.That way you would easily know where the problem lies.I've tried it and it really helped.Just to let you people know something useful.

8th Jun 2017, 6:54 PM
Asif
Asif - avatar
479 Answers
+ 152
it's nice to comment a code but there are some drawbacks as well. Like if developer updates logic and forget to update comments. or some times logic is not explainable in comments, so we should keep this in mind while putting comments in code.
14th Jun 2017, 4:07 AM
Popat
Popat - avatar
+ 96
@ASIF Thank you, for sharing the tip!
8th Jun 2017, 7:01 PM
Manual
Manual - avatar
+ 94
Learn Python theHard Way was one of the first books I read about programming, many years ago. That is definitelyy one practice I've taken the heart and you're right that it helps. I'm generally the kind of person who spends a lot of time on organization, taking notes, creating documentation and commenting my code. Some people place more focus on getting as much coding done as possible, and of while that is also vital, I think a solid foundation for learning and working that you can apply to anything is what will eventually help out rise above the the rest. Whether I'm learning a new language, a library or a framework, using new tech or simply reading about better practices to improve myself, I always work in a similarly obsessive fashion. I try to pay attention to how every little line of code works and a write extensively. Some of it ends up on my blog, but most of it is just for my own use and will likely never see the light of day. As an example, I'm learning to use Mongoose (MongoDB for NodeJS) right now. Also, as a more general goal, I'm trying to make use of ES6 and functional programming wherever possible, while avoiding only doing some things out of habit (like using jQuery and SQL databases). The basics of Mongoose are easy to get a hang of and it's possible to get started fast if you know Node.JS. But I've still rather been writing a long Markdown document detailing its usage, API and how ES6/functional programming can be used with. I've saved related Gists (I LOVE using Gist for learning and random snippets) and bookmarked several dozen bookmarks, with tags and all. I don't want to to just know ABOUT NoSQL databases - I want to be able to say with confidence that I'm skilled in their usage. A lot of time, all these tutorials and and the possibilities the languages, their hundreds of libraries and all the other technology offer, can feel overwhelming. But when you get down to individual lines of code, the big picture gets a lot clearer.
28th Jun 2017, 12:34 PM
Taija
Taija - avatar
+ 58
Good tip. I usually say it out loud as I talk to myselves a lot.
14th Jun 2017, 12:44 AM
Jamie
Jamie - avatar
+ 56
Search for 'rubber duck debugging'.
9th Jun 2017, 5:19 AM
Pav
+ 50
Great tip 👍
9th Jun 2017, 7:46 AM
NimWing Yuan
NimWing Yuan - avatar
+ 46
Another great tip for debugging is adding sensible print statements inside function/method's body where the issue is or inside many functions/methods to find the problematic function/method printing values of variables etc. But be sure to print clear statements, e.g: "Now in destructor", etc. this way u can watch variables and program flow and know when and why values changed. This can be also be done in IDEs using their "Watch" window.
23rd Jun 2017, 6:17 AM
Syed Abdul Wahab
Syed Abdul Wahab - avatar
+ 44
Don't forget to eat.
29th Jun 2017, 3:15 PM
Zakaria Belyamani
Zakaria Belyamani - avatar
+ 41
pay attention to capitalization, also instead of coding, write out your programs on paper then plug them in and see if they work, doing this will force you to be more aware and notice little details better without having to go back and figure out why there is an error as often
23rd Jun 2017, 9:14 PM
Damon Black
+ 37
IMHO, it is just like verbalize what you doing when you doing something complicated. It is very useful for tracking your menthal point and moving to the aimed result.
8th Jun 2017, 9:08 PM
Mansur Safiullin
Mansur Safiullin - avatar
+ 31
thanku for your useful tip for coding. A true coder wants to know than he can achieve anything in programming world and he can automatically mind thinks no one can try the coding for getting likes or comments .any one want to try the coding for useful in any part of life than that coding wants to used in any part of everyone life. in that aspect every programmer must think about the coding. from that automatically the likes and comments are get across u.all the best to all
29th Jun 2017, 3:19 PM
BALAJI.M
BALAJI.M - avatar
+ 29
That actually is a good tip
8th Jun 2017, 7:14 PM
Allan Stewart
Allan Stewart - avatar
+ 28
really very helpful tip
14th Jun 2017, 12:47 PM
kumar gaurav
kumar gaurav - avatar
+ 28
thnx..nice tip!
27th Jun 2017, 4:52 AM
annie
+ 27
That's very true, the comment helps a lot
10th Jun 2017, 11:25 AM
Lilgenius
+ 26
great thank you
18th Jun 2017, 1:21 PM
Li Haji
Li Haji - avatar
+ 26
tq
29th Jun 2017, 3:25 PM
BALAJI.M
BALAJI.M - avatar
+ 23
It's a good practice, but in your work this practice can mess up you or delaying you in your tasks.
16th Jun 2017, 2:38 AM
Rodrigo Temóteo
Rodrigo Temóteo - avatar
+ 23
id like to note that this tip is always useful for any new language whether it be you are learning html (a mark up language) or programming, anything that is technical and allows comments i advise this. never be afraid to break your code its the best possible way to understanding what exactly is happening and add it to your comments if you feel the need to do your research first for yourself! if you truly are lost ask for help to understand what something is. programming is about self learning just as much as it is team building.
29th Jun 2017, 3:42 PM
Daen Rowe
Daen Rowe - avatar
+ 22
here's a few tips: ... find something to focus on focus on one thing at a time; ... one task at a time; ... as you're learning something talk to yourself as you are learning it try to talk yourself through it after that then try to say it as if you were teaching someone else; ... as if you were teaching a class; ... imagine what some of your teachers sounded like while they were teaching class try to say it like that out loud that auditory sense will reinforce your memory; ... write things down it'll reinforce your memories as well, that's a visual and a touch; ... any chance you get to teach somebody once you learn something do that, ... answer that question because you figuring out how to say it will reinforce your ability to do that too!!! ... and now main thing, ... imagine yourself as doing what it is that you are learning imagine yourself going through each step... because anything that you imagine yourself to be doing will be reinforcing your memory
14th Aug 2017, 12:49 AM
Shawn Gillis
Shawn Gillis - avatar