Never Just Copy Code

When I’m learning something new that involves coding, I’m always grateful when working code examples are provided. Whether I’m working on training modules, looking up how to accomplish a specific task, or troubleshooting code. While I try to learn what I can from reading, I’m much more of a hands-on person and learn best getting my hands dirty, so to speak.

However, I very much understand there are pitfalls for using these code examples. Namely, it is very easy to simply just copy/paste the code and that’s it. If it works, all good. But do you actually know what the code does? If it breaks or doesn’t perform as expected, can you troubleshoot it? If you wanted to alter it to behaving differently, can you? This is why I press on myself to never just copy code.

Whenever I copy code, I make a habit of breaking it down. I make sure I understand every part of the code, what the code does, and how it does it. I want to make sure I know what I’m doing and learning from the code example so I can further improve my own knowledge.

For example, I’ve never worked with asynchronous programming prior to writing my project Discord bot. I was fortunate that the Discord .NET community has really great documentation on how to get started. with all the necessary code. When I was following the documentation and using their code, I made sure to break down each line to make sure I knew what I was writing. This even lead me down a rabbit hole of reading the Microsoft documentation for understand what asynchronous programming is.

I’ll be honest, I’d have no idea how to troubleshoot my bot if I ran into any issues. Not going to say I’m an expert, but I definitely learned a lot about asynchronous coding.

It’s always good to keep learning.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s