#I think it can be very hard to predict
1 messages · Page 1 of 1 (latest)
Agree, this is why I came to this conclusion:
I think it would have been smarter to just make the game and then extract the utility classes as needed when working on the next thing.
I also use this as a rule of thumb for code repetition. Repeating myself twice is okay but not more.
My question was more - when I actually make a utility class (e.g. by stealing it from a previous game), might just copy pasting and modifying the class directly in the new game be the best approach?
The idea I had with utility base classes was that it would let me work on multiple projects simultaneously and not worry about having to fix the same bug in multiple places, but now I kind of doubt I will and also think fixing in several places might be preferable over having to work with generic base classes.
Short answer to the original question: static functions
Copy + paste
Otherwise you can use upm
That's the proper way
Generally I'd be very skeptical of sharing a base class between projects
This is perhaps the longest typing time I've seen on discord
ah sorry, kind of misread the original intent of the question-
I'm not sure if there's really a wrong approach to it and it depends on the scope, size, and generality of the code
I feel in most cases anything more than keeping a template folder that you can just copy and paste into the new project and then edit from there is overkill. Making a truly general library & package API that will update across multiple projects and also have backwards compatibility with any changes you make is a lot of extra work and restriction, and really only needed in a serious production environment with a clear and established use-case in my opinion
I agree that having things be static where possible is great, less state and side effects.
But as an example of a module I know I will reuse is a tooltip system I've written.
Question is just if it makes sense to:
- Keep a general version in a utility library.
- When needed copy past the whole thing and modify directly in the game.
- Fixs any bugs/making any improvements that need to be made to the utility class in at least two places, the utility class and in the game you are working on at the time.
The downside I can think of is that if I have multiple projects going I have to make the same changes in all projects separately.
With UPM I would still need base classes that I couldn't put game specific modifications in right?