The answer to that question is entirely dependent on context, which is
stripped by using anonymous labels as you have. For linear things, the
second one is clearer, for hierarchical things the first is.

It is entirely possible to test each piece of an hierarchical
structure; this is the basis for unit testing. If you take a look at
how Go authors conventionally write helpers (you'll see this throughout
the stdlib and in the golang.org/x packages) the naming conventions
foster an intelligibility, while factoring out code and so 1. making it
testable, and 2. preventing the details getting in the way of the
bigger picture (at each hierarchical level).

To be perfectly frank, providing a mechanism that allowed people to put
more code into functions, as the with system you're proposing appears
to, would IMO harm intelligibility and I'd reject code that used it in
PRs.

Dan

On Tue, 2020-03-03 at 14:37 -0800, Warren Stephens wrote:
> rog,
> 
> Very well said -- but everyone keeps talking about improving the
> maintainability without talking about the "comprehensiblity".
> 
> Look at the 2 things below.  Which is more quickly comprehensible? 
> We cannot conceive of a way to have the upper one and still test each
> piece???
> 
> Warren
> 
> AAA
> BBB
>    www
> CCC
>    xxx
>       yyy
> DDD
>    zzz
> 
> ===========
> 
> AAA
> BBB
> www
> CCC
> xxx
> yyy
> DDD
> zzz
> 
> 
> 
> -- 
> 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 golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/be59057f-bd56-4b57-9e23-3c59b1153a47%40googlegroups.com
> .


-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4dd2dc98749307286eb346cc2c21b156ac70cf89.camel%40kortschak.io.

Reply via email to