php - what's the purpose of factories? -


i'm trying understand why object should created using factories , not new operator? example:

$validatepost = validation::factory($_post); 

instead of

$validatepost = new validation($_post); 

the static method factory of class same:

public static function factory(array $array)     {         return new validation($array);     } 

this way have 1 method objects created with. , if need add additional functionality creating, example, models, override original factory() method own in application folder.


Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -