Reading Code~
I think everyone would agree that the ability to read code is imperative to being able to write good code. It has been just recently that I personally have realized how "breaking down" code in my own words has helped me become a better aspiring developer and student.
How I read code~
In the beginning, I had heard that before you begin to write code, you should at least know how to read it. I thought that maybe the syntax or keywords may be the most important part of that process. It turns out I was wrong 👎
Don't get me wrong! Syntax and keywords are super important! However, the LOGIC behind syntax is what I really wanted to know...
As a soldier, it was imperative that complex concepts be "broken down" into smaller, easy to digest concepts so that every other soldier could understand, regardless of their education level. So when I read code to myself or out loud to anyone else, it looks like this.. ⬇️
A simple example
// a little JS
document.querySelector('div').addEventListener('click', myFunction);
In this short example code snippet, I try to take the entire idea into account and find myself asking the question
What does the dev want this code to do???
Look at the elements Dannohhh! Looks like we're working with some HTML elemnts! Sweet! I know a div element is about to be manipulated in some way. because we're "grabbing" it with a querySelector() method. Perfect, now lets do something with the div! Maybe we want to addEventListener?? YUP! moving on, what are we going to listen for? A CLICK event. And finally, what's going to happen after that 'click'? Well, it turns out that myFunction is going to happen!
So in my 🧠~
This says to me: Dannohhh, pay attention! This code is going to grab the 'div' element from the DOM, and listen for a click, when the div is clicked, myFunction will be executed! Likely causing AWESOMENESS to happen!
Thank you so much for reading and hopefully this helps someone!
Top comments (0)