Reputation: 31377
If Domain Object = Business Object, then I was expecting to see things like findTaxValues(); or searchBooksByAuthor(); methods, instead, I see generally getters and setters.
1)
Is this a Domain Object Class ?
class Application_Model_Guestbook
{
protected $_comment;
protected $_created;
protected $_email;
protected $_id;
public function __construct(array $options = null)
{
if (is_array($options)) {
$this->setOptions($options);
}
}
public function __set($name, $value)
{
$method = 'set' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
throw new Exception('Invalid guestbook property');
}
$this->$method($value);
}
public function __get($name)
{
$method = 'get' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
throw new Exception('Invalid guestbook property');
}
return $this->$method();
}
public function setOptions(array $options)
{
$methods = get_class_methods($this);
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (in_array($method, $methods)) {
$this->$method($value);
}
}
return $this;
}
public function setComment($text)
{
$this->_comment = (string) $text;
return $this;
}
public function getComment()
{
return $this->_comment;
}
public function setEmail($email)
{
$this->_email = (string) $email;
return $this;
}
public function getEmail()
{
return $this->_email;
}
public function setCreated($ts)
{
$this->_created = $ts;
return $this;
}
public function getCreated()
{
return $this->_created;
}
public function setId($id)
{
$this->_id = (int) $id;
return $this;
}
public function getId()
{
return $this->_id;
}
}
Update:
2) Since it seems to be a Domain Object Class:
I'm having a hard time studying Zend Quick Start guide.
Here's my resume so far:
Table Data Gateway Objects – Those are object copies of our tables and they should contain table related generic queries. On Zend, we will use them to perform generic queries that will work across different database vendors via Zend_Db_Table_Abstract extension. What will those gateway objects do? They will connect (via an adapter) to our data source (ex: a MySQL database), on a generic (non-database-specific) way;
Data Mappers Objects - Those objects will work between our data source and our domain object models. They may, or may not, use the Gateway to have access to the data source. Their job is to, while referring NOT to a specific table BUT to a domain (that may need/have access to different tables), it provides a way to better organize the data and the related behaviour. On this Zend example, we will use the mapper to move data back and forward between Domain Objects and Gateway Objects;
If the above is correct, then I'm still missing this:
Domain Objects (a.k.a Business Objects) – Those objects … I don't get here... what is their relation with the others ?
How can we properly define Domain Object - regarding this Gateway / Mapper architecture ?
Upvotes: 3
Views: 653
Reputation: 64943
I believe you're confusing business managers or something like that with domain objects. A domain object should be a business entity, so I'm going to confirm that your code sample is a domain object.
EDIT | Answering to your update:
A domain object is an entity playing some business role around in some specific business concern. If I don't understand wrong Zend's definitions, "Data Mapper Objects" could be "domain objects", but not in all cases.
Upvotes: 1