ドメインモデル

0pt

ドメインオブジェクト使うパターン

J2EE(よく知らない)やRuby on Railsに始まり、昨今のフレームワークはだいたいこのパターン

トランザクションスクリプトは処理をオブジェクトにするパターンドメインモデルは実際のもの(簡単にいえば1件のレコード)をオブジェクトにするパターン

<?php
class PageStrategy{
    protected $pdo;
    protected $isPublicSql = 'select * from page where id = ?';
    function isPublic($id){
        $result = $this->pdo->query($this->isPublicSql, $id);
        // .....some procedure
    }
}
class Page{
    protected $id;
    protected $strategy;
    function __construct($id, PageStrategy $strategy){
        $this->id = $id;
        $this->strategy = $strategy;
    }
    function isPublic(){
        return $this->strategy->isPublic($this->id);
    }
}

$page = new Page(new PageStrategy());
if ($page->isPublic()){
   // ...
}

「ドメインモデル」について友人に書いてもらう。

あなたにとって「ドメインモデル」とは?

ログインするとワンクリックでキーワードを投稿できます

ログインする 新規登録する

他の人の「ドメインモデル」を見る