Damien wrote:
Hi all,
Say you may want to create an instance in multiple ways, such as creating
from scratch or loading from a database. Is something like this normal for
creating an instance?
I do this:
class Foo {
function Foo($id=0)
{
if (is_int($id) && (int)$id > 0) {
return
"creating from scratch or loading from a database" sounds like you want a
registry or service locator. Otherwise, you should encapsulate object
instantiation in factory methods/classes
On 4/11/07, Damien <[EMAIL PROTECTED]> wrote:
Hi all,
Say you may want to create an instance in multiple way
Hi all,
Say you may want to create an instance in multiple ways, such as creating
from scratch or loading from a database. Is something like this normal for
creating an instance?
class Foo
{
function Foo($method)
{
switch ($method) {
default:
$method = 'create';
case '
3 matches
Mail list logo