Clean Code: Intro, Clean Code and Meaningful Names (up to the end of chapter 2)
Nate Finch
nate.finch at canonical.com
Thu Sep 26 14:04:53 UTC 2013
Function length is a different chapter ;)
On Thu, Sep 26, 2013 at 10:00 AM, Frank Mueller <frank.mueller at canonical.com
> wrote:
>
> People complain about single letter variable names, but if the function is
>> only 10 lines long, does it really matter? You can see s := thing.State()
>> ... so you know it's a state. Does it make it clearer to call it state
>> when you see it used 2 lines below? I don't think so. That being said,
>> it's fine to call it state, too. It's just when you call it
>> thingStateForReviewLater that it actually makes the code harder to read
>> when it's used in more than trivial expressions.
>>
>
> You said an important fact here: if the function is only 10 lines. Beside
> speaking type and function names, and variables that may have very short
> names based on their visibility, it is helpful to keep the functions short.
> They should be readable on a screen without problems (and no, Roger, I
> don't mean your 20"+ screen in portrait mode *smile*). Otherwise nested
> blocks should be moved into own functions (with speaking names) even if
> they are only used once. In that case the top level function using those
> sub-functions reads better and the maintainer gets a fester overview about
> the intention of the function.
>
> mue
>
> --
> ** Frank Mueller <frank.mueller at canonical.com>
> ** Software Engineer - Juju Development
> ** Canonical
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju-dev/attachments/20130926/37ff01f9/attachment.html>
More information about the Juju-dev
mailing list