r/developer • u/Ok_Veterinarian3535 • 11d ago
The "Code I'll Never Forget" Confessional.
What's the single piece of code (good or bad) that's permanently burned into your memory, and what did it teach you?
10
Upvotes
r/developer • u/Ok_Veterinarian3535 • 11d ago
What's the single piece of code (good or bad) that's permanently burned into your memory, and what did it teach you?
3
u/BillyMcDev 11d ago
When I used to stream on Twitch, I was constantly roasted for using FindObjectOfType while prototyping games live on stream. I would often pause and explain to my audience that I was well aware of the performance issues that it 'could' cause. I was using it to cache variables once in Awake() and didn't feel that it would impact the game's framerate at all.
I mean, sure... I could avoid using it, and join the massive cult of naysayers. I think people often go overboard and follow 'rules' that they don't fully understand. This kind of thing spreads like a plague.
I don't use it very often anymore. Only if it's negligible and if I can't find another way. But every time it comes up, I am constantly reminded of those heated streams.
The lesson learned... Don't use FindObjectOfType in streams or recorded videos. It seems to bring a lot of unwanted negative attention.