Profiles feature

According to the role of classification

  • The action profile can be divided into two types:
  1. Configuration item file, a file that contains all the software configuration items, software configuration read from the file, more flexible.
  2. Settings to save the file, a file storage software to set parameters.

File storage

Binary

  • advantage:
  1. A small amount of data,
  2. Write fast, fast performance,
  3. No need to parse
  • Disadvantages:
  1. Readability is not good, if you need to manually modify, it would be more trouble

String is stored

  1. xml
  2. json
  3. Custom format, for example: window under the ini file format,
config1=xxx
config2=xxx
  • Compared:
  1. Original custom format string is hardly better than json.
  2. xml json smaller than the amount of data readable similar analytical point and better performance, is relatively json suitable format.
  • And binary comparison of the advantages and disadvantages:
  • advantage:
  1. Readable, easy to manually modify
  • Disadvantages:
  1. Some large amount of data, you need to parse

database

  • Embedded database sqlite is also suitable for saving the configuration
  • advantage:
  1. Good readability, ease of management
  • Disadvantages:
  1. Read performance handicap

Options

Configuration Item file

  • Files are manually modified, the program simply reads, and therefore more appropriate to use human-readable json
  • It does not require additional information fault tolerance

Save the file settings

  • Save the file settings do not need to manually modify the program are modified, so do not ask readability, use the appropriate binary comparison
  • Use json, xml and other character format is also possible, but high performance requirements, consider the frequent need to set hardware performance, the best measure, Embedded need to consider this point, but the computer can consume without worry.
  • Optimized way json and other forms of:
  1. The configuration items split into a plurality of file storage, reducing the amount of data written to the file, but the disk space consumption point

Actual product

Problems encountered

  • The company's own embedded products, has been in the iteration, the new version of the device can be placed on a server upgrade, configuration files are not deleted after the upgrade; when the configuration file structure changes, the new version did not read the old configuration file handle, not to returns to the decision is likely to cause program Ben collapse
  • The configuration file structure has not changed, there is no problem

Appeal

  • After the upgrade user profile can not be lost

Approach encountered

  • Binary File size judgment: judgment is equal to the number of files byte structure byte is not the case re-initialization parameters, can be ruled out changes in the structure of body size; but in the case of the same size, this strategy can not be ruled out, it will lead to can not find errors,

design

  1. After the configuration file structure changes, it should withhold useful information and new default configuration merge,
  2. Because the user's profile is uncertain which version, need to add a version number
  3. Existing version and upgrade version, a combination of a variety of circumstances, can achieve a function dedicated version of the content conversion, after the upgrade, the server implementation is also more appropriate, because when upgrading a server already know the version information of the device
Released eight original articles · won praise 0 · Views 843

Guess you like

Origin blog.csdn.net/qazw9600/article/details/99757933