"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Day / Days of Code: Lessons on Scope

Day / Days of Code: Lessons on Scope

Published on 2024-11-04
Browse:173

Sat, August 24, 2024

Today’s lesson was all about scope, which is incredibly important in programming. We definitely don’t want our data to be unintentionally rewritten by a function!

A conversation with a senior developer got me thinking about the use of global variables. He'd mentioned that there are times when he uses them, which piqued my curiosity. So, I asked Perplexity AI about how often software companies follow best practices regarding local or block scope. It turns out global variables are sometimes used in legacy code, quick prototyping, to avoid refactoring complex code structures, for configuration variables, and for thread-safe storage. These insights were really insightful!

Even better, the AI discussed the tradeoffs and concerns associated with using global variables. One interesting point was about code reviews. I learned that code reviews are nearly continuous and performed at all levels as part of ongoing quality control. They can be very comprehensive, which makes sense intuitively but was new to me.

Despite some unrelated tasks that popped up, I managed to stay productive. Overall, it was a great day of learning!

Day /  Days of Code: Lessons on Scope

Release Statement This article is reproduced at: https://dev.to/jacobsternx/day-54-100-days-of-code-lessons-on-scope-3h11?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3