私のコードスニペットは次のとおりです。
public void execute(Parameters params) {
Long requestType = params.getRequestType();
// Based on the requestType the name of the project would be different
getName(requestType);
// Same as above
getDescription(requestType)
// Project here is a collection of different requests
Long projectId = createProject(name, description)
RequestContents requestContents = params.getRequestContents();
for(RequestContent requestcontent : requestcontents) {
Long requestId = createRequest(name, description, projectId);
updateRequest(requestId, requestContent1);
}
// Based on the requestType, mail content would differ
String mailContent = getMailContent(requestType, projectId)
sendMail(mailContent);
}
sendMail
関数、createProject
、の出力はにcreateRequest
依存するrequestType
ため、これらの関数は複数のif-else
条件を持つことになります。これを避けるために、このクラスをモデル化する正しい方法は何ですか?