[go-nuts] Re: Why should i use interface composistion

2018-03-13 Thread Henry
I would recommend doing the simplest things to make it work, and resort to more complex stuffs when you actually have the need for them. In the beginning, there were no *best practices* and people just took the easiest way to get their jobs done. Over the years, programming practices evolve.

[go-nuts] Re: Why should i use interface composistion

2018-03-13 Thread matthewjuran
Interfaces are not for grouping variable behavior, interfaces are for allowing generic code to apply to varying data structures. Consider a struct of function fields for grouping variable behavior without a backing data structure. If your interface type is not an input in the same package then

[go-nuts] Re: Why should i use interface composistion

2018-03-13 Thread prades . marq
The answer is it depends on the context. There is no way to answer that question without looking at the full codebase and what method will call a type implementing the Store interface. In general, you should only put the methods in an interface the consumer of a value will use. given a

[go-nuts] Re: Why should i use interface composistion

2018-03-13 Thread Jason E. Aten
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