News Feed
Sections




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

Tobias Schlitt's Blog:
Avoid an endless pifall
February 15, 2007 @ 09:03:00

Tobias Schlitt has provided a helpful hint for developers working with lots of objects, methods, and singleton patterned functionality to keep out of the same trouble he faced.

During my current exam phase I'm working on some tiny private project to relax after learning. In there I'm using a main controller class, which implements a singleton pattern and initializes several sub-controllers while being created. The singletons purpose is, that the other controllers can access to main controller and its functionality whenever they need, without storing a reference each.

The problem with the code (he gives snippets) was a recursive loop that was suddenly appearing. He finally tracked it down to a constructor in another class that was accessing the main controller's constructor. The issue was that the constructor was never finishing up, so a valid instance wasn't returned, so the whole thing started all over again.

0 comments voice your opinion now!
singleton pattern object nested constructor controller singleton pattern object nested constructor controller


blog comments powered by Disqus

Similar Posts

Hasin Hayder's Blog: An interesting bug in ReflectionParameter object in PHP 5.2.1

Eran Galperin's Blog: The Advancing PHP Developer Part 5: Design Patterns

phpaddiction: Url Routing with PHP - Part Three

Seastian Bergmann's Blog: Object-Relational Behavioral Patterns

Guilherme Blanco's Blog: register_superglobal("¯name"¯);


Community Events

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


opinion voicesoftheelephpant series community conference composer laravel php7 interview performance framework application introduction api version library podcast symfony2 example release

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