翻訳者レビュー ( 英語 → 日本語 )

評価: 52 / 0 Reviews / 2013/08/30 23:42:34

英語

I described Value Object as a small object such as a Money or date range object. Their key property is that they follow value semantics rather than reference semantics.
You can usually tell them because their notion of equality isn't based on identity, instead two value objects are equal if all their fields are equal. Although all fields are equal, you don't need to compare all fields if a subset is unique - for example currency codes for currency objects are enough to test equality.
A general heuristic is that value objects should be entirely immutable. If you want to change a value object you should replace the object with a new one and not be allowed to update the values of the value object itself -

日本語

私はValue Object をMoneyや日付範囲のような小さなオブジェクトと説明した。それらの主な特徴は、参照セマンティクスより値セマンティクスにもとづくということである。
それら(オブジェクト)が等しいかどうかの概念は id ではなく、2つのオブジェクトの持つ全てのフィールド値が等しいかどうかで判断できる。すべてのフィールドが等しい場合でも、すべてのフィールドのサブセットが一意である場合はすべてのフィールドを比較する必要はない - 例えば通貨オブジェクトの通貨コードは、等価性をテストするのに十分である。
一般的な解決法は、Value Object がイミュータブル(完全に不変)でなければならないことである。
Value Object を変更した場合、そのオブジェクトを新しいオブジェクトで置き換える必要があり、それらValue Object の値を書き換えてはならない。

レビュー ( 0 )

翻訳者レビューはまだありません