php - Passing objects to DI in group isnt it a bad sign? -
basic form of di:
class testclass { private $obj; public function __constructor($obj) { $this->obj = $obj; } }
but if have pass 20 objects, coming same origin , cant know 1 used? so, database models:
class testt { private $forum, $forumthread, $users, $posts; public function __constructor($forum, $forumthread, $users, $posts) { $this->forum = $forum; $this->forumthread = $forumthread; $this->users = $users; $this->posts = $posts; } }
anytime when new model presents, code changes. not mention if there more test* classes. if do
class models { private $forum, $forumthread, $users, $posts; public function __constructor($forum, $forumthread, $users, $posts) { $this->forum = $forum; $this->forumthread = $forumthread; $this->users = $users; $this->posts = $posts; } } class test { private $models; public function __constructor(model $models) { $this->models = $models; } }
it best, isnt it? sadly havent seen article groupping classes way.
Comments
Post a Comment