What to store in app preferences, numeric / string representations, or objects?
I have been thinking for a while about what to store in project settings, objects or numeric / string representations of these objects to set a rule and not think about it in the future, so I want to take the best approach.
On the one hand, storing object representations provides you with what is stored and keeps you from performing conversions every time you access them. You only need objects with an attribute.
On the other hand, storing the numeric / string representation of the object makes it easier to edit the parameter, since at the end the user will enter numeric or string information.
What are you doing about this problem?
a source to share
Interest Ask. Personally, I try not to store complex objects in the settings, because (in my opinion, this is subjective), it makes the code harder to understand for the maintenance programmer. I usually use simple types (sting, int, etc.) in settings.
In cases where I have a complex object with many properties, I can store the property values in a settings file.
For example, let's say you have a custom ErrorLoggingModule that has properties such as "DatabaseConnectionString", "ApplicationID". (We use something similar to this and every application we write gets a unique application ID. This gives us a central error logging database for ALL of our applications.)
I would store each of these values in a settings file and have one error logging routine. This procedure will create a new ErrorLoggingModule object, read the appropriate parameters from the file and apply the values from the settings file to the corresponding properties, and then do whatever I need to do.
a source to share