0

When application wants to create new Aggregate based on an already existing Aggregate, we are allowed to copy everything ( except for the inner entities's IDs ) inside the existing Aggregate into a new Aggregate. But if some inner object references an object outside the Aggregate boundary, we're not allowed to also copy the referenced object.

a) I know Aggregates should mind their own business and not interfere with other Aggregate's life cycle, but what exactly would be wrong if we also copied the object existing outside the Aggregate boundary?

4

1 に答える 1

2

Orderオブジェクトのコレクションを含む集約がOrderLineあり、既存の注文に基づいて新しい注文を作成する場合、注文とそれに関連付けられた注文明細のみをコピーするとします。注文明細に への参照が含まれている場合でもProduct、製品は集計の一部ではないため、製品をコピーすることはできません。

注文明細行は、理想的には製品インスタンスへの参照さえ持たず、製品 ID のみを保持する必要があります。

eulerfx が言及したように、コピーの背後にある理由は、もう 1 つの洞察を与える可能性があります :)

于 2013-01-22T04:25:00.913 に答える