When passing values to a function, we can either use the parameter list or define a structure. In my recent work, I think the previous method is better.
For example:Code:
// Pass value through parameter list
Public Void Create ( Long Param1, Long Param2, Long Param3)
{
..
}
// Pass value through Structure
Public Sealed Class Classojbect
{
Public LongParam1;
Public LongParam2;
Public LongParam3;
}
Public Void Create (classobject OBJ)
{
..
}
In the first method, if we add a parameter to the parameter list, we need to modify many other places in the project, because it is a public method, compile immediately, and report an error immediately.
In the second method, if we add a parameter to classobject, we do not seem to need to modify anything, because the parameter only references the classobject address, not the member variable in it, therefore, there will be almost no errors during compilation.
On the surface, the second method is better, because after the system is modified, the system itself has no adverse effect. However, the second method may cause bugs.
Because create is a public method with global calls, we must ensure that all functions that call the create method can assign values to new parameters in create. The second method cannot provide such a guarantee. because the system has no response, we must find all the places where create is called by searching, and assign values to the new member variables of the classobject object.
The first method can solve this problem well, because we can accurately find the place to call create through the error information generated during system compilation.
Although the first method changes a lot and may affect other modules, it blocks all the changes in the compilation phase. I don't think anyone will want to introduce new bugs because of changes to somewhere in the system.
But the second method is useful. However, this topic has ended. I hope your colleagues can share their opinions.