Dependency injection in constructor, method or just use a static class instead?
Posted
by
gaetanm
on Programmers
See other posts from Programmers
or by gaetanm
Published on 2014-08-20T11:57:40Z
Indexed on
2014/08/20
16:34 UTC
Read the original article
Hit count: 379
What is the best between:
$dispatcher = new Dispatcher($request);
$dispatcher->dispatch();
and
$dispatcher = new Dispatcher();
$dispatcher->dispatch($request);
or even
Dispatcher::dispatch($request);
Knowing that only one method of this class uses the $request instance.
I naturally tend to the last solution because the class have no other states, but by I feel that it may not be the best OOP solution.
© Programmers or respective owner