dddshelf / ddd-in-php-book-issues

Leave your comments, improvements or book mistakes as an issue! Thanks ❤️
https://leanpub.com/ddd-in-php
28 stars 2 forks source link

p26 no examples of Projection classes exist #45

Closed nealio82 closed 8 years ago

nealio82 commented 8 years ago

$projector = new Projector();

$projector->register([
new Infrastructure\Projection\Elasticsearch\PostWasCreated($client)
// ...

Neither Projector nor Infrastructure\Projection\Elasticsearch... can be found in the book's text. The reader can't implement a projection of their application state without doing a fair amount of external research. To get a working implementation I had to inspect / use an example of Proophessor's projections

theUniC commented 8 years ago

First of all, thanks again to take the time to open an issue. In fact, the part of the chapter you're referring to, it's only an overview of the most important architectural styles. It's out of the scope of the chapter to dig in this details. Anyway you can find a working example at the gamify application (a full-blown event driven application powered by an evensourced engine) used on the Integrating bounded contexts chapter.

https://github.com/dddinphp/last-wishes-gamify/blob/master/src/AppBundle/Infrastructure/Projection/Projector.php#L5

And example projections at

https://github.com/dddinphp/last-wishes-gamify/blob/master/src/AppBundle/Infrastructure/Projection/Elasticsearch/ElasticsearchUserEarnedPointsProjection.php

Cheers.

nealio82 commented 8 years ago

Ok, thanks. However I think it's confusing, as everything leading up to this is covered with code examples, but fetching the application state at any given moment isn't.

The previous section (2.4.1) gives a comprehensive code example of the write model and leads the reader into assuming there will be a working example of the read model and of write model projections. And the quote here reinforces the assumption:

An important feature of this architectural style is that the read model should be completely disposable since the true state of the application is handled by the write model. This means the read model can be removed and recreated when needed using write model projections.

The italicising of "write model projections" gives the impression it is a concept which will be explored deeper

theUniC commented 8 years ago

OK. I see your point. I've read again the chapter and I agree that adding a projection example can clarify things up. I'll add one.

We may add a chapter to the appendix just to talk about CQRS and ES. I think that would be the proper place to explain those architectural styles in more detail.

Thanks again!

nealio82 commented 8 years ago

I agree that a chapter at the end is a good idea. For me it's a natural extension of DDD and should be advocated as much as possible. I've found it very hard to find useful examples of CQRS/ES in PHP online so sections 2.4 (Command Query Responsibility Segregation) & 2.5 (Event Sourcing) made me very excited.

theUniC commented 8 years ago

Sorry for the delay. I have added a more detailed example of write model projections. The book is now being generated with the new content and you should receive an e-mail shortly. Thanks again.