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

Few more suggestions #53

Closed nicoSWD closed 8 years ago

nicoSWD commented 8 years ago

You're making great progress! :) Lots of issues were already fixed since I started writing this post, but I have a few more suggestions:

2.4.1 The Write Model

public static function writeNewFrom($title, $content)
{
    $post = new Post(PostId::create());

    $post->recordApplyAndPublishThat(
        new PostWasCreated(PostId::generate(), $title, $content)
    );
}

Perhaps I'm missing something, but what's the difference between PostId::create() and PostId::generate()? I assume it should read the same in both places, but even then, wouldn't it create two different Post IDs and cause inconsistency between the created post and the event that was published?

Furthermore, may I request to change this line:

$post = new Post(PostId::create());

Into this:

$post = new static(PostId::create());

?

The class declaration may not be on the same page in the book as the named constructor (depends on font-size and PDF reader), and by using static it becomes immediately clear it's creating an instance of itself, and the person reading doesn't have to scroll back up to see where they are. Plus, you're using new static in some other places already, so I think it makes sense here too.

2.5 Event Sourcing

This store is called an eventstore.

If we were using a database table to store the state of all the blog posts and another one to store the state..

Obviously, in terms of performance, it is expensive for an aggregate to go over its full event history every time to reach its final state all of the time.

2.6 Wrap-up

As there are plenty of options for architecture architectural styles, you could get may have gotten a bit confused in this chapter.

theUniC commented 8 years ago

You're completely right. There's a typo there. I'll fix it along with all the other suggestions. Thanks! :)

theUniC commented 8 years ago

Done! The next time the book is published all of this suggestions will be available. Thanks again!