I'm trying to establish a convention on how to execute queries from our UI (controllers) layer. Here are my three options:
Any guidance or suggestions would be great!
I tend to use a class per query, as I find several advantages to it. Each query class follows the single responsibility principle better, but also follows the open-closed principle better as well - it is easier to make changes in a system by adding new code and not changing existing code when each query is encapsulated in its own class. It is also easier to systematically apply cross-cutting behaviors like logging, authorization, and caching using aspect-oriented techniques when each query is its own class.
On occasion, I will design a single query class with multiple overloads for calling the query with different sets of parameters, but I try to do this only when the result is logically the same only retrieved from slightly different contexts - the amount of reusability between the overloads is a good indication of whet