Should I create multiple scripts for each OOP class or have multiple classes in one script?

So I have a cooking game that I am creating, and in it there are going to be appliances such as ovens, sinks and chopping boards.

I am taking an Object Oriented approach to the game, so I am wondering if I should have a separate module script for each class (appliance), or contain all of the classes and their functions in one script.

I am only foreseeing one unique method per appliance, which would be to actually perform the appliance’s function. However, it could lead to messy/unreadable code if I go with this approach.

I think I already know the answer, which is to have each class in its own separate script, but at the same time it seems pointless having a script with only 100 or so lines.

Any opinions would be appreciated!

You’ll want one module script per object. When coding, a rule of thumb is one script per feature.

4 Likes

It depends. Having multiple classes in one script can be easier to integrate but is usually harder to read.

I always put classes in individual module scripts.

2 Likes

Ok, I’ll stick to that rule then, thank you!

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