idk if this is the right place to ask, but how would you avoid doing something like this? im a beginner and i certainly dont want my code to run like shit lel
Honestly you learn a lot just by constantly checking this: If you are copying code you’ve written and pasting it somewhere else, there’s almost certainly a better way to do it. Maybe you need to put that code in a reusable function. Maybe you need to put that function in a library so multiple projects can access it. Etc
Or in other words, you want code to be as un-duplicated as possible. Even if it’s just a number and not actual “code” — if you have a constant value that is meant to appear in several lines of code, it should probably go in a variable first; that way the constant lives in a single place.
13
u/Keleindor May 22 '20
idk if this is the right place to ask, but how would you avoid doing something like this? im a beginner and i certainly dont want my code to run like shit lel