The taste of the code (reposted UMLCHINA, in what circumstances, under what circumstances, refactoring)
(Instead, this is Erptao.org, a post about Code Smell in the Refactoring Forum, I will continue to repume it here in the future) When I need the refactoring? The taste of the code is a high level programmer's "good program" A feeling, they have a capability, even if the specific implementation of the program code can see if your design is reasonable. If the code has "异 味", you need to perform refactorying. 1. Duplicate code even if it is a two-sentence repetition, repeat also needs refactoring, sometimes repeat is not so obvious, you need to do other refactoring to see it first. The code is repeated. Exclude Code Repeat is one of the most important research topics of OO software project 2. Long Method is from the process-oriented idea, even if it is possible to display on a page may be too long. 3. Large Class) A class contains too much responsibility and behavior 4. There are too many parameters, and there is no need for too much parameters. 5. Inconsistent changes (DIVERGENT CHANGE) Do not put things with different speeds. Do not put a method to a portion of each subclass of changes and the invariant portion. Do not put the instance variables per second in the object and change the force variables in one month to change ... and so on. 6. Shotgun Surgery Change The impact on too many classes and methods 7. Feature envy is too interested in data in other objects 8. Data is used by Data CLUMPS, they should have their own Class 9. Primitive Obsession (Primitive Obsession) Replaces the original data type 10. Switch statement is object-oriented by other methods to process these methods dependent methods. 11. Parallel Inheritance Hierarchies is sometimes useful but sometimes unnecessary 12. Lazy class is not enough to become a class, it should be excluded 13. Speculation Generality Don't think too much about future Flexibility 14. Message Chain has a hard sex to couple the customer and navigation structure. 15. Middleman (Middle Man) If all of his things are assignment, then it should be deleted. 16. Inappropriate intimacy limits knowledge and understanding of other internal structures. 17. Incomplete library class (Incomplete Library Class) must expand an additional function 18. Data class should add tasks and behaviors to process its data 19. Rejected legacy (Refuse Bequest) ) Subclasses rarely use the parent class to give them something 20. Note (Comments) Note is a great place to explain why instead of what.