3 ms·
Every time I have to write a duplicate XYZServiceResponse instead of ServiceResponse<XYZ>, I don't think "Hey I can't do stuff", I think "I have to copy and pas
by bigdubs 12y ago
Every time I have to write a duplicate XYZServiceResponse instead of ServiceResponse<XYZ>, I don't think "Hey I can't do stuff", I think "I have to copy and paste the same code AGAIN."
- robmccoll 12y agoPerhaps you should instead be composing an XYZServiceResponse that implements the ServiceResponse interface?
- bigdubs 12y agoCan't json deserialize things to interface{} and then use members.
- robmccoll 12y agoGood point - throw in a parent struct type. http://play.golang.org/p/oASRdqN0eQ http://play.golang.org/p/oASRdqN0eQ
- ChikkaChiChi 12y agoGood pull, but are there really that many use cases in production code where you need to consume JSON that you don't have an expectation of what types of data are coming your way?
- bigdubs 12y agoif you have a standard ServiceResponse wrapper with meta information and a 'response' field that is the actual contents of the response. Leads to FooServiceResponse, BarServiceResponse vs. if you just have a generic ServiceResponse<T>