## 5 Discussion
### Refactoring Results in Terms of the Level of the Coupling Mechanism  
Table 6 lists the results of the improvement in the complexity of each module including CarModule, DirectionCtrl, CarSimulation, Vehicle, Object_Management_Group, Profile, tagged_value, tagMotorStatus, and tagCrosswalk_traffic_light at each checkpoint time. However, it is not necessary to refactor the tagged_value, _tagMotorStatus, and tagCrosswalk_traffic_light modules because of their 0 complexity values. The second row of Table 5 shows the complexity values of the code before refactoring at the first baseline time. There are decreasing complexity values at each checkpoint time after refactoring, that is, we get low complexity values for all modules at the three checkpoint times. The difference between couplings scores of _CarModule_ is reduced as \(174-109=65\). Additionally, the difference between coupling scores of _vehicle_ is also reduced as \(142-47=95\). The coupling scores of the remaining modules are also reduced. Here, the coupling score of _tagmotorStatus_ and _tagCrosswalk_traffic_light_ is 0. This means that those codes are the dead codes. Therefore, deleting these two modules does not affect the entire code. Identification Results in Terms of Performance Degradation Factors of the Basic Control Structures of 'CarModule'  
Figure 18 shows the performance between before and after refactoring of the smart traffic control simulator. After identifying _CarModule_ with the highest coupling value of baseline time in terms of the level of the coupling mechanism in Table 5, we focus on improving the performance degradation factors of _CarModule_. In Figure 18, we show the original information of 'before-refactoring' with the number of calling, execution time [ms], number of performance degradation factors such as _Multiple_if_then_else(1000000, 686.3778[ms], 4)_, and the changed information of 'after-refactoring' such as _Multiple_if_then_else(100000, 664.9939[ms], 0)_. \begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline \begin{tabular}{c} **Checkpoint** \\ \end{tabular} & \begin{tabular}{c} **CarModule** \\ \end{tabular} & \begin{tabular}{c} **DirectionCtrl** \\ \end{tabular} & \begin{tabular}{c} **CarSimulation** \\ \end{tabular} & \begin{tabular}{c} **Vehicle** \\ \end{tabular} & \begin{tabular}{c} **Object.** \\ **Management.** \\ **Group** \\ \end{tabular} & \begin{tabular}{c} **Profile** \\ \end{tabular} & \
\begin{tabular}{c} **Tagged.** \\ **value** \\ \end{tabular} &
\begin{tabular}{c} **tagCrosswalk.** \\ **traffic\_light** \\ \end{tabular} \\ \hline \multirow{2}{*}{Baseline} & \(138+36=174\) & \multirow{2}{*}{12} & \(6+12+6=24\) & \(6+28=142\) & \multirow{2}{*}{8} & \(20+6\) & \(20+18=26\) & \multirow{2}{*}{0} & \multirow{2}{*}{0} \\  & & & & & 142 & & & & \\ \hline \multirow{3}{*}{Checkpoint1} & \(\begin{array}{c}113+36=149\end{array}\) & \multirow{3}{*}{12} & \(6+12+6=24\) & \multirow{3}{*}{6+28=18} & \multirow{3}{*}{8} & \(15+6\) & \(16+14=30\) & \multirow{3}{*}{0} & \multirow{3}{*}{0} \\  & & & & & 118 & & & & \\ \hline \multirow{3}{*}{Checkpoint2} & \(97+32=12\) & \multirow{3}{*}{7} & \(2+8+2=12\) & \(29+3+6+18=36\) & \multirow{3}{*}{3} & \(16+6\) & \(12+10=22\) & \multirow{3}{*}{0} & \multirow{3}{*}{0} \\  & & & & & 56 & & & \\ \hline \multirow{3}{*}{Checkpoint3} & \(\begin{array}{c}92+17=109\end{array}\) & \multirow{3}{*}{2} & \(2+3+2=7\) & \(6+10=47\) & \multirow{3}{*}{3} & \(11+6\) & \(7+6=4=17\) & \multirow{3}{*}{0} & \multirow{3}{*}{0} \\  & & & & 47 & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Refactoring results. In other words, before refactoring, we can see the number of degradation factors. As we show above, \"multiple_if_then_else\" modules have the digit 4. \"Loop_3\" module has 1, \"Loop_2\" module has 8, and \"Loop_1\" module has 1. After refactoring, we see an improvement in the values of these degradation factors to zero. The execution time between the modules is reduced, which implies that the CPS-based software speed has improved after refactoring of the code.