First, we recommend two tools: resharper and dotcover.
- The Code should be able to be read by others with less comments, rather than simply understanding the machine.
- If you think your code is ugly, You Need To refactor it.
- Avoid repeated code as much as possible
- When necessary, you can use static variables to save the queried data. We recommend that you set static variables to read-only and private, and access them through the read-only attribute.
- Treating static variables and static attributes differently
- Directly calling methods in static attributes does not improve performance, but static variables can
- Exercise caution when using readable, non-Private Static variables or attributes
- Code exposure is as low as possible (internal is not used to protected)
- The data type of the parameter should be as strict as possible (for example, use int instead of string)
- The definition of a local variable is as close as possible to its use, which facilitates code refactoring.
- If local variables are involved in the Code logic before they are used, they should be reconstructed as methods
- If a nested loop or condition judgment occurs in the code, this code should be restructured.
- We recommend that you use using to introduce the namespace, instead of writing the namespace to the Declaration when declaring the object.
- Remove unused using
- Remove unnecessary comments and deregistered code During refactoring
- Unless otherwise specified, it is recommended that a method not exceed 30.
- If necessary, you can use LINQ to query links of Multiple lists.
- Use List <t> instead of datatable as much as possible, which makes it easier to use and avoids excessive packing and unpacking.
- If you think your code is ugly, refactor it.
If something is wrong, please make a brick and correct it. Thank you!
To be continued