Skip to content

Commit 3920043

Browse files
author
lanyuanxiaoyao
committed
修改文件: _posts/2017-06-15-srp.md
1 parent 0f9b75e commit 3920043

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

_posts/2017-06-15-srp.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,30 @@ public class MailUtil {
180180
到此,重构的工作基本完成,运行通过,经过重构之后的结构如下图
181181

182182
![SRP][2]
183-
可以看到结构已经清晰了不少,已经按照四个主要步骤将功能分割开,基本实现了单一指责原则(自认为(´_`))
183+
可以看到结构已经清晰了不少,已经按照四个主要步骤将功能分割开,原本臃肿的`PromotionMail`类现在只剩下3个方法,出去`main`方法,就只剩下处理发送邮件逻辑的`PromotionMail`和`sendEMails`
184+
```java
185+
public class PromotionMail {
186+
187+
UserService userService = new UserService();
188+
ProductService productService = new ProductService();
189+
190+
public static void main(String[] args) throws Exception {
191+
File file = new File("src/main/java/com/coderising/ood/srp_restructure_1/product_promotion.txt");
192+
boolean emailDebug = false;
193+
PromotionMail pe = new PromotionMail(file, emailDebug);
194+
}
195+
196+
public PromotionMail(File file, boolean mailDebug) throws Exception {
197+
//
198+
}
199+
200+
protected void sendEMails(boolean debug, MailServiceConfiguration configuration, List<Product> plist){
201+
//
202+
}
203+
}
204+
205+
```
206+
至此,基本实现了单一指责原则(自认为(´_`))
184207

185208
# 总结
186209
暂略,先让老师看看再说

0 commit comments

Comments
 (0)