Email exercise design for Monday precon

Here is the simple Email design for the Monday Framework Design precon that Jim Beveridge and I worked out:
 
Samples:

// send a simple text message
Email.SendMessage("bob@mybusiness.com", "Hey Bob, how's it going?");

// send an e-mail with attachments
Email email = new Email();
email.AddFile("CoolPic.jpg");
email.Message = "Hey Bob...";
email.Send("bob@mybusiness.com ");

Class Design:
 
public class Email
{
    public static void SendMessage(string sendTo, string message) {}

    public Email() {}

    public string Message
    {
        get;
        set;
    }

    public void AddFile(string fileName) {}

    public void Send(string sendTo) {}

}

In hindsight, a few comments (and we'll see what the experts say...)

  • A "From" property or argument may have been helpful, if we can't infer who the message is coming from
  • We purposely ommitted CC, Subject, and BCC, because they weren't specifically requested in the requirements
  • "To" is necessary in order to send, so we enforced that by making it part of the methods used to send the e-mail - could have made it a property with exception logic in the Send method, I suppose
  • Tried to handle the simple case in a simple way, by providing static SendTo method
  • Should probably deal with streams instead of just file names, but this provided a really simple way to handle attachments, and the goal was simplicity
  • Once again, in order to provide simplicity we didn't handle multiple "To" strings - we could have used a collection or something, I suppose
Published Tue, Sep 13 2005 2:33 AM by Joshua Langemann
Filed under:

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 3 and 7 and type the answer here: