I’m in a dilemma about what’s one of the best ways to design repetitive issues.
Is it higher to have three strategies for three instances (that follows Single Accountable Principe?) or one technique with if-else statements? My resolution is beneath, however I’m open to ideas whether it is designed nicely or no.
public static String generateMessage(ApiOrder apiOrder) {
String message = "Howdy " + apiOrder.getCustomerDetails().getFirstName() + " " + apiOrder.getCustomerDetails().getLastName();
if (apiOrder.getStatus().equals("Validation")) {
message += "nnwe simply obtained your order and your order is in progress: n";
} else if (apiOrder.getStatus().equals("Accepted")) {
message += "nnYour order is accepted: n";
} else {
message += "nnYour order is canceled: n";
}
message += "nProduct ordered: " + apiOrder.getProduct() +
"nPackage ordered: " + apiOrder.getProductPackage();
if (apiOrder.getStatus().equals("Accepted")) {
message += "nInstallation date: " + apiOrder.getInstallationDetails().iterator().subsequent().getInstallationDate().format(DateFormatter.formatter);
} else {
message += "nReason: " + apiOrder.getComment();
}
message += "nnIf you did not order this service from ***, please contact us instantly.";
return message;
}
What I’ve to do is to assemble three related e mail our bodies, however just a little bit totally different relies on order standing.