IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Which object should send an email?
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.
--

Drew
Expand Edited by drook Jan. 27, 2010, 02:10:32 PM EST
New cat file | mailx -s "resnt email" user@addy.com
if its a one off, do it manually
If we torture the data long enough, it will confess. (Ronald Coase, Nobel Prize for Economic Sciences, 1991)
New I'd put it in the List class.
In fact, maybe I'd make a way for a degenerate, once-off special List to be made for just this event whose purpose is to subscribe exactly one User to exactly one Message, send just that mesages (i.e. no subscription messages at all) and then throw itself away.

Actually, it wouldn't be a special List at all: the controller/dispatch logic would respond to a request to Resend That Message to This User and create a new List object as I just described for just that purpose. The only special things would be that you would have to teach the List how to not send any subscription messages and to be self-deleting once the Message is sent. It need not even be saved to the database. :-)

My recommendation is based on the fact that all the knowledge you need about sending a Message to a User is *already* in the List object.

Wade.

Q:Is it proper to eat cheeseburgers with your fingers?
A:No, the fingers should be eaten separately.
New Almost agreement
Of the four classes you listed...
* 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

I'd create (at least) a 5th. Probably a 6th as well.

5th would be Messages (which might be your queue) It's a collection of messages.

6th would be MessageBO (MessageBO). It would know how to take a message off a Messages(Queue) and send them. It would be responsible for the bulk of actually pushing a message off to SMTP.
     Which object should send an email? - (drook) - (3)
         cat file | mailx -s "resnt email" user@addy.com - (boxley)
         I'd put it in the List class. - (static) - (1)
             Almost agreement - (Mycroft_Holmes_Iv)

Only Olaf Stapledon ever succeeded on this kind of scale, and Olaf Stapledon is dead.
148 ms