dimanche 26 mars 2017

Which class pattern is better?

Which pattern is better? The first class is more object-oriented, but maybe the second is easier to duplication of code copy, maybe easier to test?

1.

class ClassName {

    public $variable;

    function __construct($variable){
        $this->variable = $variable;
        return funName()
    }

    public function funName() {

        $model = ArrayHelper::getColumn($this->variable); 

        return $this->render('view', [
            'variable' => $this->variable, 
            'model' => $model
        ]);
    }
}

2.

class ClassName {

        function __construct($variable){
            return funName($variable)
        }

        public function funName($variable) {

            $model = ArrayHelper::getColumn($variable); 

            return $this->render('view', [
                'variable' => $variable, 
                'model' => $model
            ]);
        }
    }

Aucun commentaire:

Enregistrer un commentaire