Problems encountered during development

Problems encountered in the development process


1. The database is first read from the cache, and then not read from the database.
2. The data that will change should be obtained from the database as much as possible, and should not be fixedly written into the program, so as to facilitate the update without changing the code and conditions.
3. It is best to distinguish the control method (APP, panel) for the product.
4. Product reporting equipment model and related product information.
5. The product can preferably report the IP address.
6. The interface return is returned in the form of a model, which is convenient for returning multiple parameters later.
7. The interface parameter transfer is carried out in a model way, which is convenient for the expansion of the following parameters.
8. Put the relevant log before and after the judgment of the language name, which is convenient for debugging and positioning.
9. The language names that throw exceptions are surrounded by try-cache statements.
10. Use the maven module to share common project resources.
11. Initialize the data Do a good job of the interface for the initialization of the relevant data, which is convenient for the rapid establishment of the environment.
12. All parameters should be empty.
13. Data preservation must have a preservation time and a modification time, and it is best to save a modification record.
14. It takes time to return front-end data.
15. The statistical data in the database can be counted by the aggregate function in the database.
16. The swager can speed up the debugging of the interface, which is convenient for debugging later, and can return to the MAP to facilitate the display of the JSON data format.
17. Sort out how to do it first and then do it again, or else you have to sort out how to do it in the process of doing it.
18. For some configuration parameters, it is best to save them in the cache (in the database), but it is not a way to get them from the cache every time. It is best to periodically refresh them to the variables in the code.
19. If too many services are nested (between servers), there will be a long delay. You can store the information in the cache, and then start a new thread to process the subsequent logic processing.
20. You can put public tools in docker to facilitate the replacement of servers later without reinstalling these tools.
21. The data format returned by Ruchen is consistent, but the data model is inconsistent, so it can be done in a generic way.
22. The use of models should be aggregated by inheriting multiple simple models, especially those returned to the WEB.
23. The database should build a table according to the function of the module field, and do not have the content of another table in one table (the application query speed can be accelerated in the same table, and it is necessary to query multiple times if not in one table), But it will be troublesome when changing the content.
24. The best URL-related constants define different parts to facilitate subsequent changes, (start with "/", and do not need to add "/" at the end)
25. The public method is written as a package, which is convenient for the use of other applications .
26. The interface of the returned object The returned object should be a new object, otherwise the object may be modified in other applications.
27. When creating a database, remember to set the encoding method of the database, such as UTF-8.
28. If the URL of some resources is related to the relevant model, it is best to write it in the front end. The server only saves the name of the URL to prevent excessive The resource path conflict occurs when the front-end interface of each product is different.
29. In the log output, using AOP and annotation methods to output in the WEB interface can be different from other log output content, which is useful for debugging. For output delimiters with this annotation, it is easy to distinguish.
30. Adding in the log can be distinguished from different user information, which is convenient for debugging and filtering.
31. Make the input parameter null processing interface, and the front end returns the unified data format.
32. There must be a database access interface (swagger method) to facilitate data management (with password verification).
33. The database must be backed up to prevent accidental deletion.
34. User data (constantly changing) and product data (less or constant) should be stored in separate databases, dynamic data should be backed up frequently, and unchanged data should be backed up regularly.
35. Add a version management number to the database to facilitate the version management operation of the data later.
36. Basic package: http (get, post), date formatting, JSON serialization (deserialization), log output processing,
37. If it is general, you can consider using generics.
38. The database saves, updates, and deletes the entry to output the log, so that the abnormal data can be located in the future.
39. It is better to add protocol conversion version and interface version for management.
40. If the data to be saved to the database needs to be used directly behind the logic, it is better to retrieve the data from the database and use it instead of directly using the saved parameters passed in.
41. The product should preferably have the function of unbinding all users from the device.
42. Each external interface is implemented by a java file, and the interface hierarchical structure is processed to facilitate interface management.
43. The database interface layer and the public interface layer are best shared by all projects to improve development efficiency.
44. When entering different working modes, display through different methods, the best way to enter is unified (such as product WIFI entry and display)
45. The URL is consistent with the controller interface hierarchy, which is convenient for positioning.
46. ​​The product unique code should be able to obtain information such as product model and category to distinguish different product types.
47. The image URL should not be written into the database, only the file name should be used to facilitate the sharing of data between the test environment and the official environment without re-importing the data.
48. The database must be backed up to prevent problems with the machine. When the machine is down, check whether the last entry of the binary log has been updated to the database to prevent data inconsistency when the data is down.
49. Make the function modular (all the content of this function is placed in this module), and the module can be copied and used.
50. When deleting the database, it is not really deleting the data, but setting a flag bit to complete
51. The dynamic information of the database is separated from the static information, which is convenient for information management
52. When designing the database, in order to reduce the number of database queries, the name can be changed. Parts are also added to the record, but it also increases the difficulty for subsequent data changes.
53. To ensure that there is no error when modifying the data (or let the front-end modify it (only one ID judgment is not enough)), you can ask the front-end to return the original data, and then read the original data from the database, and compare whether it has not been used by the front-end. modified. It is better to write the API according to the number of parameters (it is also convenient for the control of permissions)
54. The List should be judged to be empty and whether the length is 0
55. Interceptors and annotations are used to manage the operation authority
56. The filter combines the URL for operation authority
57. Custom annotations to verify data validity
58. The role of SQL views 59.
ERP operation data verification:
data necessity, legality verification (AOP can achieve)
data rationality verification (repetition, uniqueness, existence) ) (business processing verification)
permission data range, the time range can be saved by defining permissions, visible fields, condition fields, and time fields.
Operation permissions can be handled by placing annotations at the interface for AOP.

60. By throwing an exception (IllegalArgumentException) , you can reduce the processing of whether the return value is empty in the code
61. The role of try cache is to capture exceptions. If they are not captured, the exception will be thrown into the JVM, and the program will interrupt execution. Therefore, if the program still needs to be executed, try cache should be used .

62. Do a unified log output method
63. The interface needs to verify the relevant parameters and output the log of the parameters to facilitate the development of
64.








Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326823210&siteId=291194637