Imagine I have updated a user interface label with a value. Since this is a label, end user cannot update the value directly and can only be changed through code.
Lets say the value is X. X could be a result of a calculation or retrieved from db. So now the label text is X.
If I need this X value for another method,
- I can use the value from the label text
- First I can store the X in a variable, update the label text from the variable and then use the variable for the method.
- I can ignore the label value and freshly calculate X or retrieve X from the db and use it for the method.
My question is What is the best practice and why?
Are there better alternatives?