Last post Jun 09, 2011 05:28 PM by montana111
Jun 09, 2011 12:49 PM|montana111|LINK
I have a web application that needs to send out email confirmations when a user subscribes to its service. I know how to use the email api, but I am wondering what the best way to integrate this into my project is. The confirmation emails will only get
sent from one page, but it doesnt seem right to just write the couple lines onto that page. I would like to abstract it out to an external class. Below are some of the consideratiosn I've made so far.
Create a new class for email. I called it Email. should it maybe be called SendEmail? I can't decide a good name for this.
Create a static method in the class that can be used anywhere on my site. -- Seems ok, but I feel like I rely on static methods far too often for things like this. Is there a better way?
Create a non static method taking in the parameters to the email api and put everything together and send it off -- Why go through the work of constructing a separate obj.
Anyway, if you guys have ideas for me, lets here em.
Jun 09, 2011 03:53 PM|LudovicoVan|LINK
I would leave the couple of lines of code into the page.
The day you have to send emails from two or more pages, you will have enough requirements to drive the abstraction and development of a static class.
The day you have to do something even more complex, you will have enough requirements to drive the abstraction and development of a class and its life-cycle.
IMO, the relevant best practice here is the keep it simple (incremental).
Jun 09, 2011 05:28 PM|montana111|LINK
Thanks! Sounds good to me. I was really debating which way I should do it, but this philosophy makes sense.