Is it efficient to create so many scripts for 3 lines of code?

I feel like we are creating to many scripts, like for the ui scripts, is it really needed to create 4 different scripts for the menus when we couldve created one script handling all main menu logic just kept it organized.

I’m still learning computer science, but my understanding is in object oriented programming, the goal is to modularize the components, and a single class (in this case each script is one class) should only cover the necessary functionality.

For example it is useful to separate the logic from the menu and the lobby into different scripts. You might have a scene that has both, but you might have another scene that just has a menu. In this case you would just need the menu class and not the lobby class. There is another level to this which is encapsulation. I suggest reading up on that if you are not familiar with it.

The other way to think about it is in terms of organization. If the menu script contains the menu class, and you are writing logic about the lobby, those aren’t necessarily the same topic. Really what I am getting at is for larger projects, it is more efficient to organize the methods by scripts rather than grouping a bunch of logic in the same script.

Hope this helps, let me know if you want a more detailed explanation.

1 Like

I also might add. There’s this weird fear of creating too many scripts, I honestly don’t know where this comes from but I’ve seen enough people said that to know it’s real, I also had it too at some point in my gamedev journey, but once you think it through, there are no drawbacks, on the contrary, it keeps everything more organized.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.