[Branch ~go-bot/juju-core/trunk] Rev 1666

Nate Finch nate.finch at canonical.com
Fri Aug 16 11:11:05 UTC 2013


On Thu, Aug 15, 2013 at 5:30 PM, Tim Penhey <tim.penhey at canonical.com>wrote:

>
> +func (s *EndpointSuite) TestEndpoint(c *gc.C) {
> +       ctx := coretesting.Context(c)
>
> What is wrong with calling a variable "context"?
>
>
Personally, I prefer variables in the 1-4 character range, because they are
less prone to typos and I find them easier to read when embedded in complex
expressions.

for example:

checker.Assert(coretesting.Standardout(context), gocheck.Equals,
information.Addresses[0] + "\n")

vs.

c.Assert(ct.Stdout(ctx), gc.Equals, info.Addrs[0] + "\n")

Being able to see more of the line at once helps me keep it in my head.
Long names make it harder for me, because it just requires so much reading
to get through the same amount of code on a line.

Obviously, you have to make sure you don't take it too far and have 10
variables with single letter names and end up with alphabet soup on each
line.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju-dev/attachments/20130816/a13c45f2/attachment.html>


More information about the Juju-dev mailing list