So I have the following problem: I need to create a data class containing a bunch of properties. I also need to have header properties and child properties since I will be using an expandable list in android. It needs the count of the header and children properties. So far so good. I saw two options here.I can create a bunch of type appropriate fields(String name, String category...) and hard code the count of header fields and children fields. That would mean every time I decide to add a new property to this data class I would have to go ahead and add it everywhere it's needed. That includes a lot of stuff like an Exporter that exports the data, an Importer that imports it, the List adapter and possibly other classes.The other option is to make the properties as abstract as possible. I came up with this Property object that contains String name; String value; Class<?> type;boolean exportable;. I will keep them in a Map<String, Property> in the data class. This way when I need to add another property to this project I will have to only add it to the data class. This is not ideal since I still have to hard code some stuff in the data class on addition but still it's only there and I won't have to go around classes touching other pieces of code. Since the exporter for an example will just go through all the Property objects in the map and export the exportables. Same with importer. The List Adapter will also get the count of properties from the sizes of the Map.The second variant seems appealing but it's tricky since the get methods will be hard coded to do things like propertiesMap.put(propertyName, new Property(propertyName, propertyValue, propertyType, exportable); which still looks quite hacky.This is a personal project so probably no one else will be reading it but I want to become better in code design so I wanted to ask the more experienced for an advice. What course should I go with if I were working with others on this project? The first solution is quite simple to read but it will require multiple editing on adding a new property. I guess I could specify that in a comment. The second solution is harder to read but it will reduce the workload. Then again I'm not experienced enough to see what other things will be needed in this project and I can't predict what part of the program will need to be extended but if I were to add properties I think the second option is better.
Properly designing a data class
design;architecture;object oriented design;data structures