Say you wrote some code below for projectA.
function do_task(){ // init my_init(); // calling a class function $v = class_A::some_method($p1, $p2, $p3, $p4, $p5, $p6, $p7); // return return $v; } Now, your boss loves it. Then he asks you to do a very similar thing for projectB. Naively, you may do:
function do_task($project_type){ // init my_init(); // calling a class function if ($project_type == "projectA"){ $v = class_A::some_method($p1, $p2, $p3, $p4, $p5, $p6, $p7); }elseif ($project_type == "projectB"){ $v = class_B::some_method($p1, $p2, $p3, $p4, $p5, $p6, $p7); } // return return $v; } Um… it would work, but imagine if you will soon have projectC, and D, and on… and what if you need to add one more parameter to the some_method function?
...