Bad taste of the code

Source: Internet
Author: User
1. Duplicated code (repeat codes)
If you see the same program structure in more than one location, you should try to combine them.

2, long method (too long function)
Too long a procedure is not conducive to understanding. Whenever a feeling needs to be described as a comment, you can write the code here into a standalone function and name it for its purpose.

3, Large Class (too large category)
If there are too many instance variables in a class, several related variables should be distilled into a component.

4, Long Parameter list (too long parameter column)
Too long parameter columns are difficult to understand and easily cause inconsistencies and are not easy to use.

5. Divergent change (Divergent)
A class is affected by a variety of changes. All corresponding changes to an external change should only occur in a single class, and all content within the new class should be counter-changeable.

6. Shotgun Surgy (Loose-elastic modification)
A change causes multiple classes to be modified accordingly. All the code that needs to be modified should be put in the same class at this time.

7, Feature Envy (attachment complex)
The whole point of object technology is to wrap the data together with the actions that are added to it. Put together things that are always changing together.

8. Data clumps (MUD group)
Put the data that always appears together in their own objects

9, Primitive obsession (basic type not paranoid)

10. Switch statements (switch thriller)
An obvious feature of an object-oriented program is that it uses less switch (or case) statements. Most of the time, when you see a switch statement, you should consider polymorphism instead.

11. Parallel Inheritance Hierarchies (parallel succession system)

12. Lazy Class (redundant)
If the only user of the function or class is test cases, it should be deleted along with test cases.

13, speculative generality (rhetoric of the future)

14. Temporary Field (confusing temporary range)

15. Message Chains (over-coupled messaging chain)

16. Middle Man (Middleman)

17. Inappropriate intimacy (contempt relationship)

18, alternative Classes with Different Interfaces (similar class)

19. Incomplete Library class (incomplete program libraries)
The format of the library (form) is often not good enough to allow us to modify the classes to allow it to complete the work it wants to accomplish.

20. Data Class (Simple)

21. Refused bequest (rejected bequest) 22, Comments (excessive comments)
When you feel the need to write a comment, first try to refactor and use the function name to express the meaning of the comment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.