A good guideline for newcomers is to avoid creating any interfaces at all.

Start with writing structs + methods first.

Interfaces impose requirements on client code. Keeping them small
means clients have fewer requirements.

Let the need for an interface arise naturally during evolution
of your code, when you have two things that need to act the same.
Take the minimal intersection of that need. That becomes a
method on a new interface.

Also, try not to return interfaces from functions or methods. Rather
consume them as input arguments and
return pointers to concrete structs when needed. 

This also makes it easier for clients to use
your code.

Quoting https://rakyll.org/typesystem/

> You can always embed interfaces later but you cannot decompose large ones.

> Language ecosystems with classical inheritance is often suffering from 
excessive level of indirection and premature abstractions based on 
inheritance which later makes the code complicated and unmaintainable.

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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to