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?
?>