Canonical guidance

Use when

Avoid

Preferred pattern

type Fetcher interface {
	Fetch(ctx context.Context, id string) (User, error)
}

Anti-pattern

type ServiceManagerInterface interface {
	Start() error
	Stop() error
	Fetch(ctx context.Context, id string) (User, error)
	Save(ctx context.Context, u User) error
	Delete(ctx context.Context, id string) error
}

Explanation: This anti-pattern is common in enterprise-style codebases, but oversized interfaces freeze unnecessary abstraction into APIs too early.

Why

Related pages

Sources