This is for a mailing list package. List owner creates a list, creates messages, attaches messages to a list along with scheduling info, users sign up and subscribe to lists.
Main objects are:
* User -- A user, what lists they're signed up to, what messages they've received, methods to subscribe, unsubscribe, deactivate
* List -- Description, what messages are attached, what users are subscribed, create a new list
* Message -- Includes subject, body, schedule, has method to populate message queue with record for all users who should receive it
* Queue -- Send or drop pending messages, list sent or pending messages
All of these operate on groups of items. ie: When you schedule a message with the Message class, it looks up all subscribed users and adds a record to the queue for each of them. When you subscribe to a list with the User class, it looks up all messages for that list and adds a record to the queue for each message for the appropriate time.
Now I want to send a single message out-of-sequence to a single user. User's mailbox was full, message bounced, they want me to re-send it.
Which class should have that method?
Do I add a parameter to the method in the Message class limiting it to only send to the one user (and ignore the schedule to send immediately)?
Or add a parameter to the method in the User class limiting it to only send the one message (immediately)?
Or ignore both and drop in into libMessage which is all static methods, just pass it the message_id and user_id and add it to the queue?
Or maybe the Queue class because ... umm, you're adding a message to it?
I've already got at least two places that insert into the queue table. I don't want a third, but the alternative is some ugly exception handling in one of the other classes.
I don't want the User class to have too much logic about the Message or Queue classes, or vice-versa, but right now they need that to be able to do both single record and set-based operations.
This would potentially be easier if I could use stored procedures, which I can't on my current hosting plan. Or it's badly factored, I'm not sure. I'm trying to do "loosely coupled" but it feels like too many things know too much about too many other things.
=== edit ===
Oh, one more thing. I also have to send administrative messages: subscription confirmation, welcome message, unsub messages, etc. Those will also be one-off, one message/one user. That should probably be in the User or List class.
And Bill, this is a web app. I'm not logged in to the mail server, so command line wouldn't work anyway.