1
我寫過類。 Loader
類將通過foreach調用多個類$tasks
這是什麼設計模式名稱(循環到呼叫類)
是否有這種設計模式的名稱?
裝載機
class Loader
{
public function handle()
{
$tasks = [
DoSomethingFirst::class,
DoSomethingSecond::class,
];
foreach ($tasks as $task)
{
(new $task)->handle();
}
}
}
通過裝載機
叫class DoSomethingFirst
{
public function handle() { //do something }
}
class DoSomethingSecond
{
public function handle() { //do something }
}
多態性...? – maesbn
http://softwareengineering.stackexchange.com/questions/108951/how-do-you-call-a-proxy-that-delegates-to-several-implementations –