Skip to content

Commit

Permalink
Merge pull request #123 from dogmatiq/79-clarify-new-semantics
Browse files Browse the repository at this point in the history
Recommend returning the same value/type from each call to `New()`.
  • Loading branch information
jmalloc authored Oct 18, 2020
2 parents 9c7beef + a5837ec commit 369db92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ package dogma
// A command message can cause the creation or destruction of its target
// instance.
type AggregateMessageHandler interface {
// New constructs a new aggregate instance and returns its root.
// New constructs a new aggregate instance initialized with any
// default values and returns the aggregate root.
//
// The return value MUST NOT be nil.
// Repeated calls SHOULD return a value that is of the same type and
// initialized in the same way. The return value MUST NOT be nil.
New() AggregateRoot

// Configure produces a configuration for this handler by calling methods on
Expand Down
6 changes: 4 additions & 2 deletions process.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import (
// updating a database or invoking an API operation that causes a state change.
// Any such state changes should be communicated via a command message instead.
type ProcessMessageHandler interface {
// New constructs a new process instance and returns its root.
// New constructs a new process instance initialized with any
// default values and returns the process root.
//
// The return value MUST NOT be nil.
// Repeated calls SHOULD return a value that is of the same type and
// initialized in the same way. The return value MUST NOT be nil.
New() ProcessRoot

// Configure produces a configuration for this handler by calling methods on
Expand Down

0 comments on commit 369db92

Please sign in to comment.