Abstract Factoryパターン(関連する部品をくみ上げて製品を作る) †
Abstract Factoryの具体例 (サンプルプログラム) †
先ほどの続き。
なお、以下のようなファイル構成になっている。
- Main.class.php
factory
Factory.class.php
Item.class.php
Item.class.php
Link.class.php
Page.class.php
Tray.class.php
listfactory
ListFactory?.class.php
ListItem?.class.php
ListLink?.class.php
ListPage?.class.php
ListTray?.class.php
具体的な部品 †
具体的な工場:ListFactory?クラス †
<?php
require_once("listfactory/ListLink.class.php");
require_once("listfactory/ListTray.class.php");
require_once("listfactory/ListPage.class.php");
class ListFactory extends Factory {
public function createLink($caption, $url) {
return new ListLink($caption, $url);
}
public function createTray($caption) {
return new ListTray($caption);
}
public function createPage($title, $author) {
return new ListPage($title, $author);
}
}
具体的な部品:ListLink?クラス †
具体的な部品:LinkTray?クラス †
具体的な部品:LinkPage?クラス †
Abstruct Factoryパターンにでてくるもの †
Abstruct Factoryパターンの利点 †
参考資料
最新の20件
2014-07-10
2014-06-07
2010-12-08
2010-11-12
2010-11-01
2010-10-25
2010-10-15
2010-08-18
2010-08-02
2010-07-20
今日の1件
- counter: 309
- today: 1
- yesterday: 0
- online: 1