File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff 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暂略,先让老师看看再说
You can’t perform that action at this time.
0 commit comments