I'm currently rebuilding a specialised ticket system at work (mainly used to support people with faults in remote sensing hardware...). Anyway, I was wondering whether doing lots of workflow type activity in an object's constructor is a good idea.
For example, there is currently this:
$ticket = new SupportTicket($customer, $title, $start_ticket_now, $mail_customer);
as soon as the object is created, it'll put a row into a database, go and mail the customer a confirmation e-mail, possibly send a text message to the nearest technician etc etc etc.
My question is, should a constructor be firing off all that work, or something more like:
$ticket = new SupportTicket($customer, $title);
$customer->confirmTicketMailed($ticket);
$helpdesk->alertNewTicket($ticket);
If it helps, the objects are all based on the ActiveRecord style.
I guess it may be a matter of opinion, but what do you think is the best thing to do?