0

I'm writing an app where I calculate a value based on user input. I store that user input in a Profile object. To make it easier to manage UI, I also am writing a JSON file to programmatically display the input for each attribute. Here is an example:

[
    {
        "name": "Annual Income Goal",
        "as_question": "How much do you want to make a year, after you retire?",
        "default_value": "100_000",
    },
    {
        "name": "Principle",
        "as_question": "How much would you invest initially?"
        "default_value": "1000"
    }
]

What would be the best way (in terms of ease-of-maintenance) to manage these attributes in terms of how the user would see it (i.e. the name, default value, etc.) alongside the actual structure of the class (which I have in a different file)?

I'm developing an app using Swift, but this question would apply for any language.

Edit: Here is a sample of the corresponding class in a different file.

class Profile {
    var annualIncomeGoal: Double = 100_000
    var principle: Double = 1000
}
Ethan Leyden
  • 192
  • 2
  • 14

0 Answers0