I was wondering if whenever I had a situation in which I had to temporarily hide some user interface element, it was enough to hide it (many frameworks provide this option), or I should delete the object in memory and recreate it later, when (with the same parameters).
What are the advantages and disadvantages of each solution? I thought that perhaps by hiding the element, you are saving state information, which can be important, and you are also saving selection time, so this may be the best way for elements to be hidden for a short period of time. But what if time gets longer? Then I would have an unnecessary object in memory all the time.
One example to give a clear idea of what I'm talking about is a toolbar that changes buttons based on some change in context. That is, as a rule, there are some buttons attached to the toolbar, but when the user selects one action in some other part of the interface, these buttons should be replaced with new ones (one of which is the "Finish" button). Similarly, when the user selects the "Finish" button on the toolbar, it returns to its original state.
I don't know if this is a stupid question, and maybe maybe I'm doing something like premature optimization ... but I will be grateful for all your answers.
source
share