Should a email messaging system be responsible for templating?
I'm writing a custom email sending service for a client. The client also wants message templating as well, but they didn't specify whether or not they wanted it in the messaging service or not. So, I'm thinking about best practice, here. Should a messaging service be responsible for templating as well? Or should the templating happen before the call to the messaging开发者_JS百科 service? What have you done? What works better and makes the most sense?
This is easy to answer with a question: Are you going to use the messaging service for sending all kinds of messages (with or without templates) or just templated ones? (a.k.a reusability of messaging service's functionality).
You mentioned two solutions in your question. Lets call them solution A and solution B.
Since clients constantly change their mind, you might have to later change whichever solution you adopted. Your implementation must be easy to change later on, so you can chose which one to implement like this:
- think that you have implemented solution A and you have to change it into B. How hard will it be and what will it involve? Let's call this result 1;
- think that you have implemented solution B and you have to change it into A. How hard will it be and what will it involve? Let's call this result 2;
- compare result 1 and 2 with pros and cons.
- Choose the one with the most pros.
You could also opt for a solution C. Make the messaging service send all kind of messages (generic) and include loosely coupled plugable templating (more specific). Package them together and you get a specific tool that you can later split with ease or add more templating implementations to it if needed.
Just my 2 cents!
精彩评论