News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

php|architect:
Static methods vs singletons choose neither
March 09, 2010 @ 09:08:09

On the php|architect site there's a recent post that splits apart the singletons versus static methods debate that seems to com up every once and a while with a better suggestion - dependency injection.

Much more important than performance is the fact that both static methods and singletons suffer from major drawbacks. When it comes to deciding between the two, you might forgo the benchmark comparison and choose the third-party candidate: dependency injection.

He mentions the "dark side" of both static methods and singletons and how dependency injection can help rid your code of both. Instead of focusing just on the benchmark numbers, DI helps you keep your code more well-structured and "smarter" by scoping things to where they need to be and making them easier to test.

0 comments voice your opinion now!
static method singleton dependency injection opinion


blog comments powered by Disqus

Similar Posts

DevShed: Polymorphism, Design Patterns, and PHP Programming

Lukas Smith's Blog: Why bother?

Padraic Brady's Blog: Zend Framework 2.0: Dependency Injection (Part 1)

PHPClasses.org: Top 10 Wrong Ideas About PHP That You Should Get Right

Marcelo Gornstein's Blog: Writing PHP applications with Doctrine2 as ORM and Ding as DI container


Community Events





Don't see your event here?
Let us know!


package release library framework symfony composer laravel introduction mvc security language opinion series voicesoftheelephpant update version interview community podcast tool

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework