Skip to content

Validate !IsNew on TopicRepository methods #77

@JeremyCaney

Description

@JeremyCaney

Currently, the TopicRepository correctly validates that the topic(s) being operated against with Move(), Rollback(), and Delete() aren’t null, but it doesn’t validate that they’re not IsNew. Similarly, Save() doesn’t validate that the parent topic has been saved. There isn’t a way to persist changes to a topic in this state.

Options

There are a few options if there are attempts to perform these operations against a new topic:

  1. Throw exceptions, since the operations cannot be fully executed;
  2. Leave it to the concrete ITopicRepository() to perform the validation, thus leaving room for e.g., in-memory data stores, but also complicating the code; or
  3. Skip persistence, treating these instead as in-memory operations against the topic graph.

The latter could potentially cover up upstream bugs by failing silently—and especially with certain edge cases, such as moving a saved topic after an unsaved sibling. But it also allows a consistent approach for working with in-memory topic graphs, independent of whether they’re saved.

Metadata

Metadata

Assignees

Labels

Area: RepositoriesRelates to the `ITopicRepository` interface or one of its implementations.Priority: 2Severity 1: MinorStatus 5: CompleteTask is considered complete, and ready for deployment.Type: BugBehavior that is inconsistent with documented or expected behavior.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions