Author Topic: Is it a good idea to split large .cs files into lots of small .cs files?  (Read 2889 times)

I am working on a huge addon, with some .cs files that are gigantic. Would it be safe to split that up into many .cs files or would loading times be horrendous?
« Last Edit: January 22, 2015, 04:26:36 PM by Crispy_ »

it's generally good practice to split things into parts. it's typically easier to work with a lot of smaller .cs files rather than one gigantic one, easier to understand, and easier to manage. modularise, mobilise, monetise.

i wouldn't worry too much about loading times; that's a one-time deal and it happens along with everything else that's being loaded. unless it's really significant (which is unlikely unless you're doing more than just executing files), the end user likely won't care or notice the effect of your mod.

When splitting things up into smaller parts, not that it always matters, you should consider the order you execute each file. If you have a file that relies on another file for compilation, you should prioritize the dependencies.

Edit: replaced end sentence with a word..
« Last Edit: January 23, 2015, 01:50:46 AM by Honorabl3 »

Split things based on what they do and what components they work with, don't do it just for the sake of splitting things. Done right it'll make your mod nicer and life easier. Do it wrong and you'll stumble around looking for which file you put a random utility function in. When writing a player class system I had 3-4 lengthy functions related to assembling and picking from lists of spawn points. They took up a lot of space, stood out from the rest of the file as part of one concise utility functionality, and once I had them working right there wasn't much more that needed to be done to them, so I split them into their own file. Have a look at Slayer's dependencies folder for an example of where it might be appropriate.