The domain is more or less straightforward — I have an article (or rather several types of articles) that I want to edit and publish. Published article is exposed through an API to public. The thing I have a problem with is further editing of a published article. Versioning, revisions, etc. are irrelevant at the moment. I just need to model this process:
- Author/editor creates an article (we have a new article)
- Author edits it and saves it (the article's data is updated)
- Author publishes it (the article becomes available to public)
- Author edits the article again and saves (the published version doesn't change, what happens to the article?)
I'm not putting it as a "state change" in my description as it might bring up the state pattern sooner than it's needed. I tried approaching the problem in the following ways:
- Article as an aggregate through which the current version and the published version can be accessed. But it seems weird as it basically references it's own versions
- Split the problem into two context (editing and publishing) and create a new PublishedArticle entity when the article is published but it doesn't really model the real situation. No domain expert will say "We create a published article from this article"
- I looked into state pattern but got lost trying to understand how to actually use it in my concrete example.
DBs/languages are irrelevant. I will gladly see anything helpful, be it a link for further research or a piece of code in any language. Thank you