I just started working with thrift and created following thrift interface.
map<string, map<string, string>> getInformationByIds(1: set<string> Ids)
As you can see, the return type is a map of maps
. I want to know wether I can improve the readability by creating a custom thrift structure. Any direction is appreciated.
Although I have trouble relating this to readability only, I can give a generic advice that might also solve that question for you.
struct
as return valueService methods are (currently) designed in a way most programming languages1) use the concept of a callable function: Although it allows for handing over 0-N arguments, you are still limited to a maximum of one return value only 2):
RETVAL function( ARG1, ARG2, ..., ARGN) throws (...)
So using as struct
as a return value in your service methods turns out to be a quite clever approach. In fact, it solves four problems at once:
How cool is that?
1) e.g. Golang is a notable exception.
2) We are not counting exceptions here, only normal data.