2 Strategies for Reading Code You Didn’t Write

🤩 Check out this Free Arduino Course 👇
bit.ly/get_Arduino_skills
**Check out our Pong Video and Code!**
• DIY retro pong game th...
**Learn to program and prototype with Arduino now! Join our membership.**
bit.ly/3F3P5jZ
**Get the code, transcript, challenges, etc for this lesson on our website**
bit.ly/3z16W7n
**We designed this circuit board for beginners!**
Kit-On-A-Shield: amzn.to/3lfWClU
FOLLOW US ELSEWHERE
---------------------------------------------------
Facebook: / programmingelectronics...
Twitter: / progelecacademy
Website: www.programmingelectronics.com/
________________________________
Now, it might come as a shocker to some folks but the more you learn how to program, the more code you end up reading than actually writing. I mean, you could be reading code in a library that you want to use, or you could be reading a teammate's code, or reading code that you wrote that you totally forgot about, whatever the case, reading code is a fundamental part of being a programmer. The better you can read and digest code, the more capable you'll be to be able to talk about that code with someone else or modify and use that code for your own purposes. In this lesson, we're gonna cover strategies for helping you read code that you may not have written. Stay tuned. Well before we dive in, I'd really appreciate if you could take a moment and click that subscribe button. It doesn't cost you but a click but it really helps us grow our KZread channel and bring you great content like this. So let's cut straight to the chase. Reading other people's code can be hard, even if it's well written code. I mean, it's pretty tough just to code something yourself. Trying to figure out what other people wrote is sometimes even more daunting. Worse yet is when you're brand new to programming, then it feels like you're reading ancient Sanskrit. So let's talk about a couple strategies to hopefully make this easier for you. So let's start with some actual code. This code right here is from our Pong video game project. If you haven't seen that video, you should check it out. It's pretty cool. This code that you see here was written by Steve, one of the technical writers and contributors at Programming Electronics Academy. He did this project just for fun and like I said, it's pretty cool. All in all, we're looking at just over 400 lines of code. That's everything, spaces and comments, but you know, it feels like a lot and if I'm being honest big pieces of code always intimidate me. I think to myself like, "Man, this is too complex "for some guy like me to understand," because I am no wiz. You know what I'm saying? So the first thing I try to do when reading other people's code is to set reasonable expectations. I should expect that it will be hard to read and understand code and that it's gonna take me a bit of time. If I think in my head that I'll just be able to pop in and understand some code from top to bottom in no time flat, I am kidding myself and I'm really just setting myself up to be frustrated. I mean, maybe some folks are wiz kids, they can read code super fast, understand it all. That is just not me. So I just try to keep it real. The other expectation I have is that there are going to be things that I should know that I will forget. For example, I should know how to write code for a rotary encoder. I've written code for rotary encoders. I've studied code for rotary encoders. But in many cases my memory is like a broken fishnet. It seems like everything I learn tries to escape out the back door. So I could sit around and kind of cry about that, or I just recognize that, "Hey, this is a feature of my brain, I just deal with it." So anytime that I'm looking at some code, if I forget something that I know I should know I don't beat myself up about it. I just look it up. Hey, that's life. So what's the moral of the story here? This is it. You are setting yourself up for disappointment if you think you'll be
CONTINUED...
bit.ly/3z16W7n
**About Us:**
This Arduino lesson was created by Programming Electronics Academy. We are an online education company who seeks to help people learn about electronics and programming through the ubiquitous Arduino development board.
**We have no affiliation whatsoever with Arduino LLC, other than we think they are cool.**

Пікірлер: 34

  • @mr.goldenrod291
    @mr.goldenrod291 Жыл бұрын

    You nailed it - output dictates input, next the process of how the input is processed to become the output. In other words, to make chocolate chip cookies, you’ll need flour, chocolate chips, an egg, etc., mixing bowl, oven, etc. Then the instructions of which ingredients to mix together first, how to bake, etc. Next task is making peanut butter cookies. I’ll make a wager that most of the “code” is the same.

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Love that analogy! Thanks for sharing!

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    @@ihateyou484 Thanks! Just doing our best to help folks out!

  • @tarifuzzaman5776
    @tarifuzzaman5776 Жыл бұрын

    Thanks... it's working... Good Job...!

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Great!

  • @d.athegreat3947
    @d.athegreat3947 Жыл бұрын

    I agree with you 💯

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks for the note!!!

  • @kenjinks5465
    @kenjinks5465 Жыл бұрын

    Thank you. Much like when learning new circuits, it is easy to be intimidated by all the components, but breaking it down into block diagrams, those hundreds of caps, resistors and semiconductors just become a small handful of areas to think about.

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks so much for watching and your note Ken!

  • @Arduino.bibassata
    @Arduino.bibassata Жыл бұрын

    Thanks your video is helpful with new idea

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Glad to hear that!

  • @mickgibson370
    @mickgibson370 Жыл бұрын

    I had a stroke. I can see the program if I read or someone is talking about it, but writing the code! I have coded from 1967 when I was 13. It was a lot different back then!

  • @keith726able

    @keith726able

    Жыл бұрын

    You sound like a FORTRAN guy! Me too.

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Best of luck on your recovery Mick!

  • @donaldkormos5529
    @donaldkormos5529 Жыл бұрын

    Yep ... you're right.

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks for the note Donald!

  • @ekeneosuagwu6919
    @ekeneosuagwu6919 Жыл бұрын

    Didn't know you had a KZread channel. Subscribed!

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks for subscribing Ekene!

  • @andrewlavey6992
    @andrewlavey6992 Жыл бұрын

    Good strategy, Mike.

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks Andrew!

  • @vhm14u2c
    @vhm14u2c Жыл бұрын

    Step into code and hover over variables and strings helps too

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks for adding this Vince!

  • @AMoktar
    @AMoktar Жыл бұрын

    Thanks that's awesome

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks for watching!

  • @TheJimtanker
    @TheJimtanker Жыл бұрын

    This is some great tips for reading code. The #1 rule that some programmers just don't follow is PUT IN COMMENTS!!!! I have a legacy tool at work written in VBA that is quite huge and is used to analyze large datasets. There are NO comments in this thing at all. Whenever I have an issue, I have to go through this thing and try to figure things out. I've learned a lot about VBA just by doing this and have put in my own comments to help myself and others. At least I'm the only one that knows how the code works anymore and that makes me more valuable.

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Thanks for the note Jim!!

  • @imuw5408

    @imuw5408

    Жыл бұрын

    Code documents itself, ie better naming

  • @aircates
    @aircates Жыл бұрын

    lol... reading ancient Sanskrit.... Funny and accurate at the same time....

  • @programmingelectronics

    @programmingelectronics

    Жыл бұрын

    Trying to throw a little humor in there when I can.

  • @belloadetayo7728
    @belloadetayo77288 ай бұрын

    please i am new to programming but in the last 3year have been learning javascript, node.js, react.js and express.js i still can not create a project or read a single code my self, please i need help to learn faster and i still dont have a job in tech till date

  • @belloadetayo7728

    @belloadetayo7728

    8 ай бұрын

    i need help

  • @SeerManMan
    @SeerManMan Жыл бұрын

    To be fair there are many problems with this particular program, it'd help to restructure it, it'd also speed it up dramatically. There are too many unnecessary branches and variables being initialized where they shouldn't be.

  • @xenosrelm9353
    @xenosrelm9353 Жыл бұрын

    Wri[ english]