You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2019/05/03 16:32:38 UTC
[GitHub] [trafficcontrol] rawlinp commented on issue #3484: TO: "info"
struct tag example for better generic endpoint handling
rawlinp commented on issue #3484: TO: "info" struct tag example for better generic endpoint handling
URL: https://github.com/apache/trafficcontrol/pull/3484#issuecomment-489158913
These are some of the general cons I see with using reflection with struct tags to generate/operate SQL queries:
- potential for typos in the struct tags
- potential for not having the _right_ struct tags
- encoding SQL statements/operations into the struct tags, instead of being able to write and read pure SQL
- might work ok for simple structs that map nicely to the DB tables, but won't work for complex structs that require updates across multiple tables that aren't straightforward
- due to ^ that, I think it would incentivize developers to write APIs that map very closely to the DB tables, and we'll end up with a clunkier API because of it
- using reflection with struct tags will become yet another path for API implementation, furthering inconsistency in implementations across the API
Rob Pike, co-designer of Go, writing about Go reflection:
> It's a powerful tool that should be used with care and avoided unless strictly necessary.
Do you think this reflection is _strictly necessary_? I think we can avoid it here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services