Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isClosed() considered to be true invariant or not? #55

Open
blindvirtuoso opened this issue May 31, 2024 · 7 comments
Open

isClosed() considered to be true invariant or not? #55

blindvirtuoso opened this issue May 31, 2024 · 7 comments

Comments

@blindvirtuoso
Copy link

Hi Vaughn.

A discussion can not be started on closed forum.
Isn't it the "true invariant" and then mustn't Discussion be a part of Forum aggregate?
And if it's really not, can you please clarify?

Thanks a lot.

@VaughnVernon
Copy link
Owner

No. Read my red book.

@blindvirtuoso
Copy link
Author

No. Read my red book.

The thing is that I've read it, but could't grasp the point

@VaughnVernon
Copy link
Owner

VaughnVernon commented Jun 2, 2024

First, consider the practicality of composing potentially hundreds, thousands, or even millions of discussions under one parent forum. Bad idea. The same goes for posts within a discussion.

You are thinking too technically, as if forum owners constantly toggle forums closed, open, closed, open, ... When a forum is closed, it's closed and rarely reopened. Eventual consistency handles the rest.

But what if a new discussion is started just before it's parent forum is closed? True answer: Who cares? It's not as if an insane dictator presses The Red Button (tm).

@blindvirtuoso
Copy link
Author

blindvirtuoso commented Jun 2, 2024

First, consider the practicality of composing potentially hundreds, thousands, or even millions of discussions under one parent forum. Bad idea. The same goes for posts within a discussion.

You are thinking too technically, as if forum owners constantly toggle forums closed, open, closed, open, ... When a forum is closed, it's closed and rarely reopened. Eventual consistency handles the rest.

But what if a new discussion is started just before it's parent forum is closed? True answer: Who cares? It's not as if an insane dictator presses The Red Button (tm).

Vaughn, thank you for the reply.

And just for a silly case if that was indeed important to start a discussion only on open forum.
Could that be a business invariant? Or a business invariant implies multiple states?
In the red book, there is an example c = a + b where a, b and c are different states.
In my example above there's just one state forum.isClosed.

I mean there are no multiple states on forum and discussion which need to be consistent for "a discussion is only allowed to be started on open forum" business rule.

@VaughnVernon
Copy link
Owner

VaughnVernon commented Jun 2, 2024

If I understand your question, yes I think it would be an invariant because a modified forum.discussions collection (one new discussion) requires forum.open==true.

To other readers, this answer is based on a hypothetical question and does not influence on modeling a new aggregate boundary. In other words, the preexisting business rules and consistency constraints have not changed.

@blindvirtuoso
Copy link
Author

That's much clear now.
Thanks, Vaughn!

@redaLaanait
Copy link

redaLaanait commented Jun 2, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants