create account

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

View this thread on: hive.blogpeakd.comecency.com

Viewing a response to: @cryptoctopus/coding-diary-entry-1-fear-and-doubts-in-javascript-world

· @scorpil · (edited)
$11.63
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](https://en.wikipedia.org/wiki/Breadth-first_search)). 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](https://en.wikipedia.org/wiki/Depth-first_search). 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.
👍  , , , , , , ,
properties (23)
authorscorpil
permlinkre-cryptoctopus-coding-diary-entry-1-fear-and-doubts-in-javascript-world-20180122t163855422z
categorycoding
json_metadata{"tags":["coding"],"links":["https://en.wikipedia.org/wiki/Breadth-first_search","https://en.wikipedia.org/wiki/Depth-first_search"],"app":"steemit/0.1"}
created2018-01-22 16:38:54
last_update2018-01-22 18:36:36
depth1
children0
last_payout2018-01-29 16:38:54
cashout_time1969-12-31 23:59:59
total_payout_value10.870 HBD
curator_payout_value0.764 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,121
author_reputation18,786,743,616
root_title"Coding Diary Entry #1 - Fear and Doubts in Javascript World"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id31,424,795
net_rshares1,031,250,910,007
author_curate_reward""
vote details (8)