I have been working for three months. Today, my mind is scattered. Let's summarize the problems in writing programs ~~
1. Real-time backup.
This is what I feel most deeply. I did not write too many programs in college, but only some small program segments may not be involved in this aspect. However, when we were new to the company, we were asked to make a small game by ourselves. This may be a relatively large program I came into contact with. We should consider playability, interface, and many other factors, there will naturally be more code. Sometimes when I modify a place, the effect after the repair is not as good as the original, because it overwrites the code modification, and many of the original ones cannot be found, which of the following sections will be modified first.
This is a relatively low-level error. With the in-depth study and work over the past three months, the importance of backup has become increasingly apparent.
When writing code, you can back up the Code if you write well and the test is normal. Back up the entire project from time to time, especially before performing some operations. (If you think manual backup is troublesome, write your own tools !)
This is also very practical in our lives. A person's mind cannot cover all aspects. Therefore, preparing a notebook may help you take notes about important things and even small things. It seems that it will benefit a lot ~ (I want to remember)
2. Record the running time.
After the training, I started the d3d training. The first thing I felt was to record the program running. When I was learning C ++, I wrote a lot of console output to find out what the program is doing. However, it wasn't about console programs. Similarly, you can write out what you want to see in real time anywhere on your interface.
On the other hand, when writing a direct program, there will be a lot of structures and a lot of functions that create pointers. These structures or functions do not have a dozen attributes or parameters, as long as one is incorrect, will fail, resulting in the failure of the entire program. Looking for these errors at the beginning wastes a lot of time, thus writing a log class. Every function determines whether the execution is successful, so that it can be quickly located when there are errors. Although I think it will increase the write time in some aspects, once an error occurs, it will save a lot of time for you to find the error.
This is only for the convenience of testing and debugging, but will increase the resource expenditure, so you can remove it when the program is mature and released, or better use preprocessing to pre-release ~
3. pre-process your program ".
When I wanted to write something, I thought about it and started typing on the keyboard. But now I think we should design it on paper. What algorithms will be used, what classes will be used, what functions are, what are the structural relationships between them, what to learn, and what to accomplish at last. A project has a series of preliminary work such as feasibility analysis, demand analysis, and overall design. We can write similar ideas, ideas, and small programs, it will save you a lot of time and help you clear your thoughts when your thinking is messy.
To expand to our daily lives, we often need to make plans and complete the plans ~
4. Learn to read your own code (review ).
Two days ago, I read a high-profile Article, which is very affected. Many beginners include experienced programmers who, after finishing the last character of the Code, start to compile and run the code immediately, so they can't wait to see their work results. There are errors that are expected to save some time for the compiler debugger to help check out, but the errors such as memory leakage that the compiler cannot check out are the most fatal. So let's review the code we have written. After writing a program, we will read it once or even several times to find low-level errors such as semicolons and letters with few variable names, then, check whether memory leaks, whether the variables are initialized, and whether the functions return values. Avoiding these errors will save you a lot of time.
You can also look at your code and compare your mind to a computer to simulate and run it, especially to simulate some boundary values. This is the most important thing. In this way, we can not only improve our own ideas, but also help us think of situations that are not handled, so that the program logic is more rigorous.
5. Pay attention to memory issues.
I will not talk much about this. It is not very profound to understand it. Let's talk about it;
Select the appropriate data type: use short without int, and save memory when the data volume is large;
Memory leakage: New pointers and objects must be release and delete;
Memory out-of-bounds: this is the worst case when the loop array appears. Pay attention to your habits;
Reference uninitialized pointer: defines a pointer that must be initialized;
......;
In short, you should pay attention to the summary and induction.
This section will be summarized later.
6. write more.
I often write about Dongdong, project summary, learning experience, recent insights, and use my notes to record them. I will have different insights in the future.