Thank you both for some feed back, I was so busy with homework yesterday forgot to check on my post.
I hope to show my code, but its still proof-of-concept code with bad names that don’t make great sense because I had no idea what I was doing. Right now, I didn’t want things I know are wrong to be the highlight of people’s responses. Eventually, when everything is working, I plan to demo it all on a asp.net site I’m working on. Because it would be cool to do so. Basically, I would like to refactor my code before I show it.
I don’t have a specific project in mind, I was just trying to understand design patterns better. I could just use the new Input system that was released, but I don’t think that will teach programming concepts. I targeted the command pattern to solve my input problem.
Though I don’t have a specific project, but I am working with extremes in mind, which I guess would be logging vast amounts of data, possibly over a network.
Let’s assume it’s a MMO. I think sending strings over a network connection is a bad idea. The Input system uses the command pattern. If an MMO, I could send just a few integers over a connection, those integers could recreate strings from the command pattern. Player to player dialogue would need a unique command who’s value is a unique player defined input, among other unforeseen challenges.
Maybe storing strings isn’t necessary. I can store the command, and the values associated with it. Then each chat window added only has 1 stringbuilder with 1 string to manage, based on the array of objects containing previous command data. Or as you suggested, keep a short list of text objects I can roll on and off the chat box. Its not as though the rolladex solution can’t also be applied to chat displayed in a chat box. Strings can be written to files if the user wants to save or log it.
Wouldn’t that be cool to click a chatbox text item, and pull up more details about the command its related to. But also be able to construct a new chat box containing all related messages related to certain values in that clicked dialog. If you wanted to isolate messages from a certain player or NPC, I think I could do it quite simply through the command pattern. I’m liking the idea of having separate text box for each string.
That’s all probably a nightmare I’ll look at later. I’m just going to get strings working for now.
In relation to me, all of this is totally premature optimization, especially considering I’m trying to optimize without any idea if what I do is actually improving things.
In relation to the program itself, I’m not sure I can call it premature because I’m not targeting a performance standard, but rather more interested in seeing how much I can front load the program. It’s a bit like the hobby overclocker who invests all his time and money trying to get 100 extra Mhz out of his processor. What practical use is that gain other than to flex ego on a internet forum?
I should really be documenting my development phases because the goal is to learn. Trying to do this has opened up doors to an overwhelming number of things I didn’t know exist. Like the profiler, and a whole unity pdf document detailing the 50 or so optimization techniques. I’m much more familiar and comfortable with Eventsystems, common design patterns and working with UI canvas related things than when I started doing this.
Conclusion
I think the take away from the dialogue here so far is I need more numbers before I start going nuts with different approaches.
To the point you guys made, the things I’m addressing might be trivial in the big picture. It’s true that I’m fretting over things like lists and and the GC when I don’t know if I should be. Other parts of a game will likely be more intense than these issues. But I don’t have a game. I have inputs and ui chat boxes.
I think before I move forward, I need a baseline to work from. Measure the performance and document to test my changes against. Because I have no idea what I’m doing.
Some help defining a practical testing criteria.
Lets say 10 chat boxes creating strings at a fixedDeltaTime which would be a max 250 strings created a second with default Time settings. Maybe I need more load to notice differences.
Measure the base performances at low and high yield string making with the profiler.
Then I can start optimizing, put in the stringbuilder, give each chatbox its own canvas, test against lists to see if I actually improved anything, etc. Collect real data on the different approaches. Hopefully, we can all have a better idea about when, what and why.