Code optimization and code optimization

Source: Internet
Author: User

Code optimization and code optimization

In my personal summary, I wrote my blog for the first time. I just want to find a place to record my thoughts and learning experiences.

 

After more than six months of work, I wrote a complicated game scenario. At that time, I was in a short time. I thought about what functions I could add directly without thinking about. When I finished writing it, I checked that there were 200 or 300 rows of header files in the slot. The naming rules are not detailed for the moment. How can this problem be solved?

The Code repetition is even more messy. Some places have different characters in four or five or eight lines. I can't see it anymore. The code with repeated features is here a copy and paste, where a copy and paste. If else writes 7 or 8 in succession !! I don't know what it means if there are many variables !!

When you want to change the file, you need to change all the items you want to use. Otherwise, you must use Ctrl + Shift + F to replace the current document !!!

This is the first time I feel that the code is really inflated. It's terrible !!!

 

When you submit code to the header, you don't need to think about it. Please optimize it for me. "I cannot understand your code"

Several XXX1 (), XXX2 (), XXX3 (), and XXX4 () functions like this are terrible now. member variables of the class XXX1, XXX2, XXX3, XXX4, and XXX5 are even more crashing!

The last 1500 lines of code were optimized to 700 lines !!!

Heaven! Earth!

I used to read some articles about code optimization and refactoring.

Think about it now ------ practice is really a good lesson for me !!!

1,

2. Some variables in the header file:

3. if else:

4. functions:

5. There are four similar code segments:

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.