lets have method like:
map<string,object> getdata()
what's way document keys , values contain, assuming list of possible keys , types of objects keys known?
[edit]
assume can't/won't change method in way that'd require changing other code, how can still sensibly document it?
i suggest use enum lists keys (and 1 value classes if makes sense in case). assuming know all potential keys front, make sense. going there: if keys known, , limited, why using string key? map<enumforkeys, object>
instead.
the nice thing can put nice javadoc on each of enum constants; see here. , know, assuming value class fixed each different key, put method on enum tells value class directly.
the next, far less appealing option have static list somewhere, contains potential keys.
edit: given last comment options of course pretty limited. in case, still use enum list potential keys, , put {@link}
javadoc of method. sure, of "informal" only; well, better nothing.
Comments
Post a Comment