Download

Class getting too long; what should I do, if anything?

Hey everyone, I was wondering what approach you guys use to manage your code length. Right now my player’s class has become long enough that it’s a pain to navigate through it. Should I just leave it be? Or maybe do something like split some parts into components? Are there any potential performance issues regarding that approach?

Thank you for any help.

It’s personal preference really.

You can split things into simple structs, or components if you feel code is becoming unmanageable/unreadable. The only time you would pay a performance penalty is if the component needed to Tick (in which case that’s one more per-frame iteration the engine has to do per however many objects you have of this type). But, there’s ways around that (store a pointer and manually call the tick yourself during your player’s tick, etc). Any performance hit is going to be incredibly slight, so I wouldn’t worry about that at all until you start seeing it in your profiler when the game/project is done and you want to see where performance is going.

I’ll probably split it into structs, thanks.