I have a server which receives requests that I have to parse in order to get the parameters for the request handler to use. Also, both the parsing and the request handler could fail in some way (e.g.: for the parser, a parameter is missing; for the req. handler: some error in a database), hence the "status" in the code below. The request handler of course gives some kind of response which I then have to send back to the client.
So I'm having trouble deciding which of the following options I should use in my "main", because I want to keep the parser separated from the handler:
1)
parser.parse(request,¶m1, ¶m2, &status)
handler.handle(param1, param2, &response, &status)
2)
status = parser.parse(request, ¶m1, ¶m2)
status = handler.handle(param1, param2, &response)
3)
Params params = parser.parse(request, &status)
handler.handle(params, &response, &status)
4)
status = parser.parse(request, ¶ms)
status = handler.handle(params, &response)
5)
parser.parse(request, ¶ms, &status)
response = handler.handle(params, &status)
6) etc., some other combination
(Params would be some kind of container for the different parameters, so for each type of request I would have a different "Params" type. Also, the "&" could mean pointer or reference, I'm using c++, but it's not relevant to the question)
Which is the easiest, clearer, best, ..., whatever?
*** There are plenty of similar questions, but none include the "status" part, so I can't make my mind yet