Where should an objects' associated objects be restored when using the table data gateway pattern?

75 Views Asked by At

I have a class User which has the property address which is an instance of Address. I am using the Table Data Gateway pattern to manage the persistence of the User object.

Assuming the Address class has its own Table Gateway, who should be responsible for setting the User's address property?

As an example of what I am asking in PHP:

<?php
$user = $userTableGateway->getUserWithId(5); // \My\Classes\User
$address = $user->address; // \My\Classes\Address  <-- Who makes sure this exists?
?>
0

There are 0 best solutions below