Hi all,

When invoking a CS API command that has parameters of type Map, the request
will be something like this:
URL/api?command=createTags&tags[0].key=region&tags[0].value=canada&tags[1].key=name&tags[1].value=bob

in order to send a Map with the pairs:

tags{
   region : "canada",
   name : "bob"
}

Then in the server side the parameters go through several stages (IMHO too
many), and have different formats. At some point

apiDispatcher#setFieldValue

will assign the value to the command property (CreateTagsCmd#tag in the
example) in a VERY strange way:

CreateTagsCmd#tag = {
   0 : {
      "key" : "region",
      "value" : "canada"
   },
   1 : {
      "key" : "name",
      "value" : "bob"
   }
}

This is true for several Cmd classes. And the funny thing is they usually
provide a public getter method to get the Map in an already "normalized"
structure. The problem is we have this method again a again in each of
these commands, only with different name depending on what property the
get, and the body is almost copy and pasted. so my next refactoring would
be to have a generic method only once in BaseCmd so that all subclasses can
reuse it for their Map getters. Pretty obvious, but...

Is it really necessary to have this strange format? Wouldn't it be much
better to just store it in a more normal way from the beginning, and have
the getters just standard getters? Does it have any use to have those Maps
of Maps?

Thanks. Cheers
Antonio Fornie
Schuberg Philis - MCE

Reply via email to