People have a wide range of perceptive and cognitive abilities. People also
have difficulty imagining the very different abilities that others possess.
I find constant vertical scanning and scrolling to be distracting and thus
inefficient. So I won't use a tool that adds line breaks to my code, and
I'd benefit from a one-line switch.
This is a good compromise, less cryptic than ?:
v = if t a; else b // else can be on next line
v = if (t) a; else b // parens isolate the test if required
And maybe that implies
v = switch t; case 1 a; case 2 b
Note that go fmt allows this clumsy construct
if err = pkg.ActionItem(); err != nil { // which op is tested?
return err
}
While exploding this clear one
err = pkg.ActionItem()
if err != nil { return err }
On Thu, Aug 16, 2018, 9:08 PM 'Kean Ho Chew' via golang-nuts <
[email protected]> wrote:
> On Friday, August 17, 2018 at 8:53:15 AM UTC+8, Liam wrote:
>>
>> I find that one-concept-per-line, yielding more compact functions, is
>> easier to focus on, as it reduces vertical eye scanning and scrolling.
>>
>> A single-line if stmnt and my switch example demonstrate
>> one-concept-per-line.
>>
>> The thing is, what is cost with the current if else expression that worth
> more to introduce another possible complications? Like my previous email
> and other developers had implied, LOC doesn't matter. In the end, the
> compiler knows what to do.
>
> It's okay to do vertical eye scanning (we're doing it anyway while we're
> coding/reviewing). When ternary logic is abused, we need to do vertical +
> horizontal scrolling.
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.