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

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -