1. 次のクラスは、「メール送信」と「テンプレート生成」を同じ場所で行っています。凝集度/結合度の観点から、どの設計が望ましいでしょうか?
class MailService {
constructor(client) {
this.client = client;
}
sendWelcomeMail(user) {
const body = `ようこそ ${user.name} さん`;
this.client.send(user.email, body);
}
sendByeMail(user) {
const body = `ご利用ありがとうございました ${user.name} さん`;
this.client.send(user.email, body);
}
}
class MailService {
constructor(client) {
this.client = client;
}
sendWelcomeMail(user) {
const body = `ようこそ ${user.name} さん`;
this.client.send(user.email, body);
}
sendByeMail(user) {
const body = `ご利用ありがとうございました ${user.name} さん`;
this.client.send(user.email, body);
}
}