This week, we mainly reviewed and improved the unfinished refactoring tasks. In this process, we also encountered problems. We summarized them. At the same time, through continuous practice, we have a further understanding of the code of the tutorial.
Taking the management of teachers as an example, this paper analyzes the relationship between the various aspects
Note: the template and query functions in template inheritance are not included
We can delete, edit and add on the main page of index. Taking editing as an example, firstly, the ID value of the object to be operated is obtained from the index, so as to obtain the information of the whole object. Then, it is passed into the V layer for packaging, and through the V layer, it is passed into the update to save and output the success and failure of the operation.
Problems encountered this week and Solutions
The problem is that when I edit the course, anyway, the output of my update is shown in the following picture:
Investigation idea: from near to far
1) The first is to check the update. It only has C layer, which is easy to check. It is found that there is no error soon.
2) . continue to check: the next layer is the V layer of edit. Because the V layer mainly packages the C layer, it does not change the value passed in by edit, just check the V layer’s pass in to update. Because of the error prompt, we know that the error information is related to the ID. through keyword query, we find that the Id only exists in the V layer, as shown in the figure below:
By checking the related fields, it is found that there is an error immediately. There is an extra double quotation mark after value, which makes it impossible to execute the contents of braces. The default value of 0 is returned continuously.
The above is the process of solving this problem. Suppose that no error is found in the V layer of edit, and then look up. The next layer is the C layer of edit, and so on.
The problem is that when you edit a course, when you jump to update, the following results are always displayed:
First of all, I checked the C layer corresponding to update and found that there was an error in the logic
Obviously, we found that else should be placed outside the first if. Suppose we find that there is no error in update through investigation, we will continue to investigate from near to far.
We obviously found that the error was uesrname, so we can find it directly through keyword query, because the prompt said that uesrname was not found in layer m, so we should find layer C and layer V at this time.
We found out what went wrong.
1. When there is a mistake, don’t look for it blindly, and analyze it according to the error tips. For example, for the first mistake, we should first analyze the possible mistakes in a comprehensive way, and use the thinking from near to far to find it.
2. When we find spelling or grammar mistakes according to the prompts, we don’t recommend to find the mistakes one by one. We should quickly locate the mistakes through keyword query.
Thoughts after the course:
My state in the first week of summer vacation:
It's so annoying. I can't remember so much code
Status of the second week of summer vacation:
I feel that if I make mistakes now, I will find them systematically. Everything is going well. I am happy to learn
Answer: for code, do not need to memorize, believe in yourself. If you still have doubts now, it may be that you have not really connected them. When you make clear the connection between them, you will find that it’s amazing that they are actually a network.
All rights reserved. The copyright belongs to “mengyunzhi software development team of Hebei University of technology”