recently I've got a request to re-factor some code in process of registration part of /shop.
While doing so, I've encountered EmailService interface and it's implementation.
(just to mention I am using BLC framework 2.3.0-M2-5)
Here is the interface:
Code: Select all
/**
* @author jfischer
*
*/
public interface EmailService {
public boolean sendTemplateEmail(String emailAddress, EmailInfo emailInfo, HashMap<String,Object> props);
public boolean sendTemplateEmail(EmailTarget emailTarget, EmailInfo emailInfo, HashMap<String,Object> props);
public boolean sendBasicEmail(EmailInfo emailInfo, EmailTarget emailTarget, HashMap<String,Object> props);
}
This pop-ups the question, why are you using implementations of HashMap and not interfaces like Map?
I would rather like to see similar thingy:
Code: Select all
public interface EmailService {
public boolean sendTemplateEmail(String emailAddress, EmailInfo emailInfo, Map<String,Object> props);
public boolean sendTemplateEmail(EmailTarget emailTarget, EmailInfo emailInfo, Map<String,Object> props);
public boolean sendBasicEmail(EmailInfo emailInfo, EmailTarget emailTarget, Map<String,Object> props);
}
Program towards interfaces rather then implementations is supposed to be "best practice".
According to one of the authors of book "Gang of four" - Erich Gamma
http://www.artima.com/lejava/articles/designprinciples.html