I'm writing a simple utility class for sending an email. I'm not sure what's the proper way to present this to a consumer. Should I force them to use an array in send()
? Or should I provide an overload so they can pass a single argument?
public class SimpleSender {
public static void send(String smtpServer, String[] to, String[] cc, String from,
String subject, String body, boolean HTML, String fullFilePath) {
SendEmail(smtpServer, to, cc, from, subject, body, HTML, fullFilePath);
}
public static void send(String smtpServer, String[] to, String[] cc, String from,
String subject, String body, boolean HTML) {
SendEmail(smtpServer, to, cc, from, subject, body, HTML, null);
}
// Should I provide this overload and similar ones?
public static void send(String smtpServer, String to, String[] cc, String from,
String subject, String body, boolean HTML) {
SendEmail(smtpServer, new String[] {to}, cc, from, subject, body, HTML, null);
}
private static void SendEmail(String smtpServer, String[] to, String[] cc, String from, String subject, String body, boolean HTML, String fullFilePath) {
.... Send email
}
}
I know it's a bit of overkill for just a simple email utility, but in general, what's a good practice for these situations?