Re: [nyphp-talk] Constructors and

2006-10-19 Thread David Mintz
Odd, I have seen examples in well-known and respected books that said things like class User { function __construct($userId=null) { if ($userId) { // load data from db and // throw Exception if not found } else { // expect an insert } } } --- David Min

Re: [nyphp-talk] Constructors and

2006-10-19 Thread Randal Rust
On 10/18/06, Matthew Terenzio <[EMAIL PROTECTED]> wrote: > Just want to bounce this off the OO gurus: By no means am I one of those, but here is how I do it: $user =& new User; $user->viewUser($rec);//gets the data for the user I want $user->addUser();//adds new user based on the data collecte

Re: [nyphp-talk] Constructors and

2006-10-18 Thread Dell Sala
I think you've got the right idea. Loading the user data should occur outside the constructor so you can check for success. A little off topic: It looks like your moving towards a DataObject pattern and if you haven't explored this already it's worth a look. DataObjects typically have somet

Re: [nyphp-talk] Constructors and

2006-10-18 Thread Matthew Terenzio
On Oct 18, 2006, at 11:05 PM, csnyder wrote: > I think it's good practice to keep actions out of the constructor. Fair enough. Just wanted to make sure I wasn't either overthinking or underthinking it. ; ) ___ New York PHP Community Talk Mailing List

Re: [nyphp-talk] Constructors and

2006-10-18 Thread csnyder
On 10/18/06, Matthew Terenzio <[EMAIL PROTECTED]> wrote: > Just seems cumbersome to create a new object and ALWAYS > follow with a given method. > I thought that's what constructors were for. I think it's good practice to keep actions out of the constructor. I typically end up wanting to change co