On Mon, 2003-09-22 at 13:25, jsWalter wrote: > > "Raditha Dissanayake" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > hi, > > > > It's generaly considered that constructors are supposed return an > > instance of that class. Use a factory instead if you want to return nulls; > > > A Factory? > > OK, I'll look that up, do some readng and try that route.
In brief -- a factory is a function or object that returns instances of some object for which it is a factory. It is based on the analogy, for instance, whereby a car factory outputs cars. A logical example of a factory might be an object that returns user objects. The interface might be something like follows: $userFactory = &new UserFactory(); $userObj = &$userFactory->getUser( $userId ); In the above example if the user ID was not valid then $userFactory might very well return null. A special case of a factory, a singleton factory, is where the factory ALWAYS returns the same object. Such a factory might be used for a session object so that there is only ever one interface object to the session data. HTH, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php