Arramis
Новичок
Вобщем, осваиваю MVC (не пинать если что не так), хотелось бы услышать критику, оценки, способы улучшения такого(стандартного !?) подхода к проектированию приложений, тоесть чем плох или хорош - обо всём по порядку.
спасибо
PHP:
// file: model.php
class Model
{
public function __construct()
{
}
public function get_data()
{
// retrieving some data from database
}
}
// file: view.php
class View
{
private $model;
public function __construct($model)
{
$this->model = $model;
}
public function display($params)
{
// building html with model data
}
}
// file: controller.php
class Controller
{
public function __construct()
{
}
public function execute($params = array())
{
$this->display($params);
}
public function display($params)
{
// connecting all components together
require_once "model.php";
$model = new Model();
require_once "view.php";
$view = new View($model);
$view->display($params);
}
}
// file: index.php
require_once "controller.php";
$params = array( /* ... */ );
$controller = new Controller();
$controller->execute($params);
Последнее редактирование: