Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: O-O design, aggregation of objects

by mpeever (Friar)
on Nov 08, 2008 at 03:55 UTC ( #722351=note: print w/ replies, xml ) Need Help??


in reply to O-O design, aggregation of objects

If I call User->new(), should that actually create a database entry?

I'm interested to see what feedback you get. But I assure you, DB writes on object creation is a bad idea. It will lead to a ton of spurious of DB writes, and possibly race conditions. In the very least, creating the objects from the DB will be interesting, as de-serializing those objects from the DB will trigger DB writes...


Comment on Re: O-O design, aggregation of objects
Replies are listed 'Best First'.
Re^2: O-O design, aggregation of objects
by dsheroh (Parson) on Nov 08, 2008 at 16:28 UTC
    ...except that you can instantiate an object without calling ->new, so the infinite loops you mention are easily avoided.

    I'd still say "no" to save-immediately-on-create because it's likely to result in a number of spurious database records being created. (I don't know about the OP, but I sometimes instantiate temporary objects which have no reason to be stored persistently.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://722351]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (17)
As of 2015-07-30 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls