2

I'm working on a system to model a Process. One property of the Process is its rate. I think the Rate is a value object since it has no specific identity. This rate is retrieved from a service (think SOA, not DDD Service) I don't own. The service can vary for each type of Process, since the Processes have teams and services built to support them that hold the data I want. How do I organize that in DDD?

Here's some code to help explain:

class Process
{
    private final Rate rate;
    ...

    public Process( Rate rate )
    {
        this.rate = rate;
    }

    public Rate getRate()
    {
        return this.rate;
    }
    ...
}

class ProcessFactory
{
    public Process createProcess( ProcessSpecification spec );
}

class ProcessRepository
{
    public Process getProcessByName( String name );
}

If ProcessSpecification includes a RateSpecification that describes which service to call for rates, should the ProcessRepository be responsible for knowing how to load rates from the various other services?

4

1 に答える 1

1

Processが集計であり、集計が一貫性の境界として機能する場合、他のソースからのデータを参照するべきではありません。代わりに、が作成されているRateときに適切な値を取得Processし、それを残りの集計と共に永続化できます。

プロセスのレートが Process 集約の範囲外で変化する場合、サービスからレート値をポーリングし、それに応じて Process 集約を更新する同期メカニズムが必要になる場合があります。この場合、レート値は残りの集計とともに保存されます。

Processさらに、レート値が表示目的でのみ使用される場合、概念的には集計の一部であっても、集計の一部であってはなりません。この場合、レートを表示する必要があるときはいつでもサービスを呼び出すだけです。パフォーマンスが問題になる場合は、キャッシングを使用できます。

于 2013-03-19T17:34:37.283 に答える