Now that our CustomerRepository can save customers as well as associated addresses in a decoupled manner we need to move onto the next problem, reconstituting our customer object with an address. As others have mentioned we may want to Lazy Load the address since there will be instances when it isn't needed.http://web.archive.org/web/20100420152400/http://steve.emxsoftware.com/Domain%20Driven%20Design/DDD%20Reconstituting%20objects%20from%20multiple%20Repositories Note! He goes on to say this is NOT the optimal solution (too much coupling)
public class Customer {
public int addressKey;
public Address Address {
get {
if(address == null) {
address = new AddressRepository().Load(addressKey);
}
return address;
}
}
Tuesday, May 1, 2012
DDD Lazy Loading
Labels:
Lazy Loading
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment