java - What is the correct way to add this field to this entity? -
i have entity
public class location{ private string name; private final set<string> sublocations = new hashset<string>(); public string getname(){ return name; } // corresponding setter public void addsublocations(string sublocation){ sublocations.add(sublocation); } public set<string> getsublocations(){ return sublocations; } }
this class populated , stored mongo db collection.
we have requirement of adding new field called "organization_group". logically, belongs under sublocation, add there.
what pasted class right now. best way of adding 'group' child sublocations? create sublocation class?
just need input on this,
thanks!
before answer question, whats difference between location , sub location ? single field name, me both class definitions same.
are aware of composite pattern ? if location class needs represent tree data, should consider using composite pattern.
now answer question, believe thinking in right direction, adding field called organizationgroup new sublocation class right way go situations.
Comments
Post a Comment