ドメイン オブジェクトから Zend へのクイックスタート チュートリアルの例と、DAO/VO パターンを考慮した他の例を見ると、両者は非常に似ているように見えます。
「値オブジェクト」と言うのは「ドメイン オブジェクト」と同じだと推測できますか?
そうでない場合は、それらの違いを明確にしていただけますか?
あるものの機能は何ですか?
どちらもゲッターとセッターによって構成されており、それ以上のものではないため、私はこれを求めています。どうやら、彼らは同じ機能を果たしているようです...
アップデート:
そのため、Zend Framework クイック チュートリアルのドキュメントでは、これをドメイン オブジェクトと呼んでいました。
// application/models/Guestbook.php
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;
}
}
1)厳密に言えば、「Anemic Domain Object」に直面しているのでしょうか?
2)ドメインロジックが含まれているという理由だけで「ドメインオブジェクト」と呼ばれていますか?
3)この場合、findBookByAuthor() などのメソッドを含むマッパー。彼らはドメインロジックも扱っていますよね?それらもドメインオブジェクトと見なすことができますか?
どうもありがとう