I'm creating a typesafe front end for a web API and I'm a little stuck at the architecture.
Basically the API works by having commands. Within the possible commands there are groups eg: Overlay or Scene. Each group has a set of associated actions and *possible* required query data with that action.
My first thought was to have something like the decorator pattern:
new Command(new Overlay(new GetMetadata....));
The main problem is that this is very verbose and also oddly rather weak as an architecture. Not every group action needs a plethora of information. If the API changes it seems like this design would be very klunky to update as well.
I was thinking that this might be better as a factory pattern, a factory for each group. Although there would need to be a method for every possible action, if changes happened in the API the user wouldn't have to care about it. the implementation could also share code between the factories, maybe even just reusing the possible decorator approach I aimed at above.
var command = SceneCommandFactory.CreateListByOwner(query, data, here);
i_CloudAPI.SendCommand(sessionInfo, command, mycallback...);
Would the factory pattern work here? Or should I look elsewhere.
Basically the API works by having commands. Within the possible commands there are groups eg: Overlay or Scene. Each group has a set of associated actions and *possible* required query data with that action.
My first thought was to have something like the decorator pattern:
new Command(new Overlay(new GetMetadata....));
The main problem is that this is very verbose and also oddly rather weak as an architecture. Not every group action needs a plethora of information. If the API changes it seems like this design would be very klunky to update as well.
I was thinking that this might be better as a factory pattern, a factory for each group. Although there would need to be a method for every possible action, if changes happened in the API the user wouldn't have to care about it. the implementation could also share code between the factories, maybe even just reusing the possible decorator approach I aimed at above.
var command = SceneCommandFactory.CreateListByOwner(query, data, here);
i_CloudAPI.SendCommand(sessionInfo, command, mycallback...);
Would the factory pattern work here? Or should I look elsewhere.