Java - Model class with so many properties vs one single HashMap<key,value> -


i trying read multiple text files ( each file having different layouts / schema's).

currently model class have more 40 properties , kind of hard coded.

i planning use hashmap<>, everytime new file comes, can read file without changing model class adding more properties.

but correct way it?

please advise.

both approaches have pros , cons. map gives flexibility schemas unknown in advance become nightmare in maintenance, , not error safe - i.e. types not checked. bean predefined properties opposite. in general better option have change every time schema changes. can have combined approach. have set of properties there. , may or may not have other properties unknown in advance. have bean predefined setters , getters , add setter , getter map property deal unknown properties. hope helps


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -