My app has a few UI pages in it with a lot of scrollable bars… think something like your email or messenger app, where you can scroll through all your conversations.
Currently, I have it so each bar’s script has an IDragHandler on it to manage the dragging of the bars. There could be upwards of 15 bars on screen at a time.
Is this more costly in CPU and memory than having the IDragHandler on the containing BarManager script that manages the bars? If it’s on the main script, then there will need to be raycasting to see which bar was targeted. In addition, this bar manager script is used on a few other pages where bars won’t need to be swiped.
I went with the ‘drag handler on each bar’ method because it’s more contained, and less sloppy… but I’m worried that all those extra components might cause unnecessary overhead?
Is the difference worth worrying about? Sorry if I havent given enough information. I’m having a hard time describing the situation while also keeping my question as brief as possible.
Do not worry about performance until you meet these criteria:
- you have determined there really is a performance problem you cannot live with
- you have used the profiler to find out EXACTLY where the problem is
Otherwise you’re just making a mess of your codebase.
Code it the most straightforward way you can reason about it. Most likely it will be fine.
If not, start with step 1 above.
Um. What? Thats like… no. Sorry. I’m way too old and cut my teeth programming where you always worry about performance first. That way you’re not cleaning up a godawful mess and trying to figure out what is going on in the profiler later.
This “dont worry about it unless it’s an issue” is why half the games on my phone destroy my battery and the simple game isn’t doing anything.
No offense intended, but, “don’t worry about performance until performance becomes a problem” is about as good advice as “thats what the steam is for. Its how your car tells you that you’re out of coolant.”
I debated posting this, because I know I’m coming off maybe a bit harsh here, but just slamming whatever you want in there and “as long as it’s not running at 12 FPS it’s fine” is absolutely terrible advice to give to any programmer and that’s a hill I’m fine dying on.
Excellent! I wish you the best then.