<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 31, 2015 at 8:22 PM, Nate Finch <span dir="ltr"><<a href="mailto:nate.finch@canonical.com" target="_blank">nate.finch@canonical.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Struct tags that are the same as the name of field are never needed:</div><div><br></div><div><div>type SomeResult struct {</div><div><span style="white-space:pre-wrap"> </span>Error *Error `json:"Error"`</div><div><span style="white-space:pre-wrap"> </span>Somethings []Something `json:"Somethings"`</div><div>}</div></div><div><br></div><div>The above is totally unnecessary... those fields will already serialize into "Error" and "Somethings". There's a bunch of this in the apiserver/params package... you don't need it, so don't do it. It just causes confusion, because it looks like you're changing the name from the default, even though you're not.</div></div></blockquote><div><br></div><div>Tim's pretty much covered this already, but I wanted to note the other big problem with the params package: that it pulls in types from elsewhere, and those types are a *massive* liability. For data that goes over the wire, and data that goes into a database, please *always* be *local* and *explicit* about what you're storing. As far as I'm concerned:</div><div><br></div><div>1) putting a *charm.Meta (or equivalent) direct into a database (or sending it over the wire) is completely unjustifiable, because you're explicitly dropping control of what you're storing/sending: some other guy can make a perfectly reasonable change to a completely unrelated package and break your wire format. This is a Very Bad Thing, where explicitly copying structures at layer boundaries is merely Somewhat Tedious.</div><div><br></div><div>2) failing to use serialization annotations is essentially the same mistake, because it makes it way too easy for a well-meaning programmer to change a field name and again, whoops, break the wire format. Changing field names is normal and good -- code evolves, abstractions change (hopefully for the better) -- and implicit serialisation has chilling effects there and leads to paranoid code fossilisation. (Or, worse, it doesn't, and we just put up with a constant risk of arbitrary subtle breakage.)</div><div><br></div><div>Cheers</div><div>William</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><span class=""><font color="#888888"><div><br></div><div>-Nate</div></font></span></div>
<br>--<br>
Juju-dev mailing list<br>
<a href="mailto:Juju-dev@lists.ubuntu.com">Juju-dev@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/juju-dev" target="_blank">https://lists.ubuntu.com/mailman/listinfo/juju-dev</a><br>
<br></blockquote></div><br></div></div>