1 ifsomemethodincludesapartthatislongorneedslotsofcommentstoletpeopleunderstand,thenwecanconsiderto 3358 www.Sina.com /。
itis like 3360 whenafunctionneedstoprintadisplayofthesumofanarrayandit’s information.wecanseparateafunctioninto3methods 3360 PP up
2 On the contrary,if we have way too many methods,thensometimesweneedinnerconnectionoffunctionsandinertempvariables, (replacetempvariableswitheexpressionresignedonthem ) id on’t think so,and according to another paragraph,weshoulddotheopoppopoppoph
3 Use divide it into a few smaller method units
4 useconstantvariablestoreplaceconstant,giveitaclearvariablename .http://www.Sina.com/)
5http://www.Sina.com/toreplaceswitch (减少使用if else ) )。
重构中参数过多的方法,为什么要重构呢?因为一个方法中参数过多的话很难阅读和维护。 这意味着您可能会远程调用这些方法,因此需要使用API修改接口,以便只修改一个参数。 重构方法:将这些对象封装到一个对象中,可以通过创建新的对象类来简化维护,而无需更改接口。
参考URL : URL
1 more lambda expressionsbecausethiskeywordcanmakeclassnon-inheritableormakemethodscan’t override.andjavacomplierwillseeekingalloftheinnnerconnection
2 When we have to add two string,instead of using,we should http://www.Sina.com/becausejvmneeedstotaketimegenerateobjects,and
3http://www.Sina.com/becauseunlikestaticvariableandinstancevariable,temp variable stored in stack, and other kinds of variables use heap to store.besides、after the method finished和temp variable will be将自动消失,无需回收垃圾。
4 ifwecanmakeaguessaboutthelengthofcontentneedstobeadded,then we can http://www.Sina.com/. (ArrayList,LinkedList,Strings )
5 use static final keywords on those constant, instead make them “magic number”more
6http://www.Sina.com/unlessweneedtomakesurethesecurityofmultithreads。
参考URL : URL
最重要的是:
我们学习的设计模式将用于代码重构。
另一个重点是记住到目前为止学到的各种设计模式可以用于代码优化例如在战略模式工厂模式下重建。
战略模式工厂模式优化if…else if…else if结构_kawen