I would say to temper judgement on both sides. 

If you’ve ever written or read Go code in an IDE and used “find implementors” 
you’ve seen the power of interface based design. Sure, you can still do this in 
Go - kind of - because an implementation may not be by design nor according to 
the semantics of the interface. 

Personally I find large systems benefit greatly from explicit interfaces. Go’s 
implicit interfaces work fine for utility code, “scripts” and internal design 
implementations. 

> On Aug 10, 2022, at 8:51 PM, 'Paolo Calao' via golang-nuts 
> <golang-nuts@googlegroups.com> wrote:
> 
> 
>> On Mon, Aug 8, 2022 at 7:17 PM Tim Peoples <t...@timpeoples.com> wrote:
> 
>> 
>> For years I've read the old adage, "Accept interfaces, return structs" and 
>> have spent years working to instill this understanding among my colleagues. 
>> I gathered a great many skills while learning Go (and acquiring readability) 
>>  back in the day -- and one of the strongest of those is the idea that 
>> interfaces should be defined by their consumer instead of an API producer -- 
>> but I've now been away from Google longer than I was there and I'm beginning 
>> to suspect that the general consensus among the Go Literati may have shifted 
>> around some things -- like preemptive interfaces.
>> 
>  
>  I don't think the general consensus has shifted. The problem of interface 
> pollution has always been around. 
>  
>> My arguments against preemptive interfaces have recently run into more and 
>> more pushback  -- especially among the influx of developers coming from the 
>> Java and/or C# world who seem to continually reject any notion that Go 
>> should be any different from the way they've always done things.
>> 
>  
> This looks to me like a cultural problem rather than a technical one. 
> Each language has its own idiom and best practices. Any programmer can decide 
> not to follow guidelines just as any carpenter is free to hit the nail with 
> the handle.   
> 
>  
>> This has recently come to a head with a brand new job (I'm 3 weeks in) where 
>> virtually all of their services are built atop a dependency injection 
>> framework having a data model with dozens (if not hundreds) of preemptive 
>> interfaces and my initial, cursory review tells me the codebase is at least 
>> an order of magnitude more complex that it needs to be.  (Note, I was told 
>> that none SWEs at this company (other than myself) knew any Go before they 
>> started).
>> 
>> So, my questions to the group are thus, "Should I even care about this at 
>> all?  Are preemptive interfaces now considered the norm with Go? Or, should 
>> I just shut up and crawl back into my hole?
>> 
> 
> IMO you should care, each of us should spread good practices and idioms to 
> increase the overall quality of Go code.
> You can leverage good references to show people your're not alone:
> https://github.com/golang/go/wiki/CodeReviewComments#interfaces
> https://www.ardanlabs.com/blog/2016/10/avoid-interface-pollution.html
>  
>> TIA,
>> Tim.
>> 
>> -- 
>> 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/f4777928-875d-4c0a-a4a7-9fb57bf9d51fn%40googlegroups.com.
> 
> 
> Privacy and Confidentiality Notice: This email and all attachments are 
> confidential and for the designated recipient(s) only. They may also be 
> privileged. If you are not the intended recipient or among the intended 
> recipients, you may not use, read, retransmit, disseminate, store/copy the 
> information in any medium or take any action in reliance upon it. Please 
> notify the sender that you have received it in error and immediately delete 
> the entire communication, including any attachments.
> 
> -- 
> 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/CABJBrS69ZRf_vaz-ChaDGjM5KStJ%3DcYuT5Tb6KnEK%3DyzONqBMA%40mail.gmail.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/D65EDC1F-D307-4C27-AA8C-F053905C7813%40ix.netcom.com.

Reply via email to