Re: Nested immutable value objects
Tom Eugelink <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
I'm not sure this is a good example. I mean, in real life a car is mutable like hell; if you put in a new engine, the car remains the same. I figure immutability is more focus to primary types. For example volume (tank) or distance (drive). So suppose you have a car, with 10 liters of fuel in the tank. car.getTank().getContents() could return an object Liter(10) If you take out one liter from that tank, then this is is not how to do thiat: car.getTank().getContents().substract(1) This would be a better way, given the volume being immutable: car.getTank().setContents( car.getTank().getContents().substract(1) ) IMHO ------------------------------------