Category: Refactoring
-
Post Views: 18 1. A code to be tested. This code comes from a simple application that supports users to view and adjust production plans. Its (slightly rough) interface looks like the picture below. as shown in Figure 1 2. The final implementation of the example code is as follows, the productionplan.html file code of the entrance is as follows…
-
Post Views: 22 1. When learning to refactor: improve the design of the existing code (2nd edition), it is found that the function statement is missing 1 } at the end, which leads to the problem of the code format display. as shown in Figure 1 2. I have always mistakenly thought that the code itself was omitted }, so…
-
Post Views: 23 1. The existing implementation is as follows 2. Reference 10.1 Decompose conditional expression (decompose conditional), adjust to the following 3. 10.2 Consolidate conditional expression (Consolidate conditional expression). Extracting the inspection conditions into a separate function is very useful for clarifying the meaning of the code, because it replaces the statement describing “what to do” with “why do…
-
Post Views: 19 1. The troupe stores the data of the play in a simple JSON file. 2. The bills they issued are also stored in a JSON file. 3. The following simple function is used to print the details of the bill. 4. Use the above data files (invoices.json and plays.json) as test input, run this code, you will…
