You are viewing a single comment's thread from:

RE: Coding Diary Entry #1 - Fear and Doubts in Javascript World

in #coding7 years ago (edited)

Unlike with human languages, you learn programming languages by writing rather than reading. At first with the help of a teacher/tutorial. Then, as soon as possible, by writing your own mini projects.

Couple of hints that are quite obvious for experts, but might be useful for novices:

  1. When reading code, starting at the top of the file is not always the best approach. Try to follow the execution order rather than line order. In your example it makes sense to start from the loop, since that's the first executed part that's actually doing something apart from initializing values.

  2. When you try to understand the big picture, you should read the code layer-by-layer (kinda like BFS). When you stumble upon a function, you shouldn't immediately jump into it to understand what it's doing. Instead leave it in your mind as a 'black box' that you will open later, once the rest of the program on the top level is obvious. For this to be possible functions in your code should be simple enough to describe them in few words, and should be named appropriately.

  3. When something is just not clear, or doesn't work as expected, it's time to dig deeper in DFS manner. Choose one input state of the program, start from the location in code close to where the problem occurs, but where the state of the program is still understood by you. Add print statements to display the values and check whether the values are what you would expect of them. Once print outputs are clear - move them closer to the "target". Repeat the loop until you've understood what's happening or bug is fixed.

  4. For me at least, diagrams are immensely useful. You don't need full blown UML, or any standard for that matter, since you're the only reader. So concentrate on content instead of form. Try to visualize what connects to what in your code with the help of lines, squares, circles and squiggles in whatever matter you find convenient.

Try it, and let me know if you found my advises helpful. Good luck in your journey.

Coin Marketplace

STEEM 0.18
TRX 0.16
JST 0.030
BTC 67167.55
ETH 2610.59
USDT 1.00
SBD 2.67