On 23/09/22, Ian Davis (m...@iandavis.com) wrote:
> On Thu, 22 Sep 2022, at 11:27 PM, Rory Campbell-Lange wrote:
> 
> I just wanted to respond to this part:
> 
> > I suppose my question is (and forgive me if this is a terrifically naive),
> > how can one negotiate the go landscape of commonly used modules to
> > re-utilise, where possible, a more commonly named interface implementing
> > "Speak()" or convertible to provide "Speak()"?
> 
> Generally, when writing Go, the consumer of the object defines the interface 
> it requires. So rather than you looking for interfaces that might exist in 
> the wild, it's better to focus on your application and its needs. If you have 
> a component that uses the Speak method on objects then define that as an 
> interface that your component can accept. Any other user of your component 
> can see that interface is needed and provide a suitable object that 
> implements it or create a shim to adapt one.

I find this is a very interesting perspective. It certainly seems easier to 
think about defining interfaces for one's own types than trying to select from 
n possible interface "contracts" on offer.

I assume, though, that it makes sense to support commonly occuring method sets 
a.k.a. interfaces to improve reusability and readability of one's own modules? 
If so, how does one go about getting to know what those commonly occuring 
interfaces are?

Thanks
Rory

-- 
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/Yy2hbfOrXGrkZN7f%40campbell-lange.net.

Reply via email to