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

More suggestions #63

Closed nicoSWD closed 7 years ago

nicoSWD commented 8 years ago

Got a few more suggestions for you guys!

**3.7.1.3 Embedded Value with Doctrine <= 2.4.***

However, if you’re stuck in Doctrine 2.4, what is an acceptable solution for using embedded values with Doctrine < 2.5? We need to now surrogate all the Value Object attributes in the Product Entity, which means creating new artificial attributes that will hold the information of the Value Object.

This reads a little weird. Perhaps I'd rephrase this to something like:

If you're stuck with Doctrine 2.4 or older, an acceptable solution for using embedded values is to surrogate all the Value Object's attributes in the Product Entity, which means creating new artificial attributes that will hold the information of the Value Object.

I'd use XML compatible comments here, because people will copy and paste this.

  <field
    name="surrogateCurrencyIsoCode"
    type="string"
    column="price_currency"
   />
    // end-of-new-code-to-take-a-look
</entity>
  <field
    name="surrogateCurrencyIsoCode"
    type="string"
    column="price_currency"
   />
    <!-- end-of-new-code-to-take-a-look -->
</entity>

...

These two new fields don’t strictly belong to the Domain, as they don’t refer to infrastructure details, rather are a necessity due to the lack of embeddable support in Doctrine.

I'd rephrase this to:

These two new fields don’t strictly belong to the Domain or infrastructure details, but they are necessary here due to the lack of embeddable support in Doctrine.

3.7.1.4 Serialized LOB and Ad Hoc ORM

CREATE TABLE `products` (
  id INT NOT NULL,
  name VARCHAR(255) NOT NULL,
  // start-of-new-code-to-take-a-look
  price TEXT NOT NULL
  // end-of-new-code-to-take-a-look
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

I'd use SQL compatible comments here for the same reasons as above.

CREATE TABLE `products` (
  id INT NOT NULL,
  name VARCHAR(255) NOT NULL,
  -- start-of-new-code-to-take-a-look
  price TEXT NOT NULL
  -- end-of-new-code-to-take-a-look
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

3.7.1.5.1 Doctrine Object Mapping Type

Uses invalid XML comments as well.

3.7.2.2.2 Collection Backed by a Join Table with an Ad Hoc ORM

It’s possible to do the same with an ad hoc ORM, where Cascade INSERTS INSERT and JOIN queries are required.

3.7.3 NoSQL

Unfortunately you don't escape from these problems.

Sounds a little incomplete.

Unfortunately, you won't escape from the problems we discussed earlier here either.

...

If you use PHP serialize/unserialize methods...

They're functions:

If you use PHP's serialize/unserialize functions...

...

you’ll be required to again rebuild the Value Object during Redis retrieval.

you’ll be required to rebuild the Value Object again during the retrieval from Redis.

3.7.3.1 PostgreSQL JSONB and MySQL JSON Type

MySQL has done the same. As of MySQL 5.7.8, MySQL supports a native JSON data type...

MySQL MySQL MySQL

MySQL has done the same. As of version 5.7.8, it supports a native JSON data type...

...

... that enables efficient access to data in JSON (JavaScript Object Notation) documents.

You've used the term JSON a million times up to this point. Why is its meaning (JavaScript Object Notation) now being explained?

...

the value need not be parsed from a text representation...

the value doesn't need to be parsed from a text representation...

...

you can decide to use a string or model the concept using a Value Object

you can decide to use a string, or model the concept using a Value Object

...

... will be checking that the string is a valid IATA code...

... will be checking if the string is a valid IATA code...

...

What’s the chance you forget anywhere important?

What’s the chance you forget an important place?

carlosbuenosvinos commented 7 years ago

Thanks again!