I am currently implementing an API usually I use manager and service patterns to implement the layers and keep the internal API callable.
But during my walk home I was wondering if it's maybe instead of having a service pattern to define certain behaviours of a an model in my module a strategy/command pattern would suffice as well.
The main thing that bugs me with the Service pattern is that Services seam to grow and grow but having just a clear UserCreateStrategy::execute(data) instead of an UserService::create(data) could reduce that bloat since the ModelService basically groups all strategies.
Still I am not sure, there is no better solution just different forms of isolation and groupings what do you guys think?
This is purely out of interest if you got some pros or cons for one those approaches.
Mark
I'm not sure I understand the situation well enough, so apologies if this is useless.
In my opinion, strategy pattern is for things that are abstractly the same operation, but with variations that you want to choose at runtime. When I think of an API, the operations aren't usually interchangeable, so I would give them different (incompatible) types.
If you're asking whether you should split each 'operation' (API endpoint or otherwise) into it's own class, then probably yes imho. That's what I understood from the "...Strategy" postfix. That seems like something that'd make the growing of functionality more manageable.
Both ways seem like Command pattern to me (the API request being the command), but maybe I'm misunderstanding the intended use.
I feel like I'm extrapolating a lot in my interpretation, so feel free to disregard if not useful.