1
ouioui
kernel : object instanciation
  • 2005/1/18 16:17

  • ouioui

  • Just popping in

  • Posts: 32

  • Since: 2003/7/11


Hi,

In the directory call kernel, why there is only one class XoopsUser whitch implement the constructor with the id : XoopsUser($id = null).
$user = new XoopsUser($id);

The others classes use the handler to make the instanciation :
example with privmessage:
$pm_handler =& xoops_gethandler('privmessage');
$pm =& $pm_handler->get($idmsg);

why there is no function in XoopsPrivmessage called XoopsPrivmessage($id = null).
Is it the volontary to be closest from the factory pattern ?

Why there is this différentes between user and the other kernel classes ? To you think it is a good think ?

Thank for your response .

2
Mithrandir
Re: kernel : object instanciation

new XoopsUser($id) should NEVER be used. It is there for backwards compatibility with older code.

New classes with the XoopsObject/XoopsObjectHandler relationship should use the handler->get($id) instead.

Preferably the only place there would ever be a
$object = new ClassName();

is in the create() method on the handler class.

Login

Who's Online

268 user(s) are online (189 user(s) are browsing Support Forums)


Members: 0


Guests: 268


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits