Login
Ekankyesme +6289627970885 https://vip.bitcoin.co.id/ref/ekankyesme http://www.empowr.com/coin?v=ekankyesme 16cqkCc82jNAKrUCUipZZdGadcTEeReGzo
ekankyesme
bikeMake = $make;
$this->bikeModel = $model;
}
public function getMakeAndModel() {
return $this->bikeMake . ' ' . $this->bikeModel;
}
}
class AutomobileFactory {
public static function create($make, $model) {
return new Automobile($make, $model);
}
}
$pulsar = AutomobileFactory::create('ktm', 'Pulsar');
print_r($pulsar->getMakeAndModel());
class Automobile {
private $bikeMake;
private $bikeModel;
public function __construct($make, $model) {
$this->bikeMake = $make;
$this->bikeModel = $model;
}
public function getMakeAndModel() {
return $this->bikeMake . ' ' . $this->bikeModel;
}
}
class AutomobileFactory {
public static function create($make, $model) {
return new Automobile($make, $model);
}
}
t$pulsar = AutomobileFactory::create('ktm', 'pulsar');
print_r($pulsar->getMakeAndModel());
?>
The main difficulty with factory pattern is it will increase the complexity and it is not reliable for good programmers.
Strategy pattern
Strategy pattern makes a family algorithm and encapsulates each algorithm. Here each algorithm should be inter-changeable within the family.
2,
'date' => '2011-01-01',
),
array(
'id' => 1,
'date' => '2011-02-01'
)
);
$collection = new ObjectCollection($elements);
$collection->setComparator(new IdComparator());
$collection->sort();
echo "Sorted by ID:\n";
print_r($collection->elements);
$collection->setComparator(new DateComparator());
$collection->sort();
echo "Sorted by date:\n";
print_r($collection->elements);
?>
>?php
>?php
>
Jumat, 27 Juli 2012
ekankyesme
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar
http://www.empowr.com/coin?v=ekankyesme