Some records on 23/04/28; the last working day before May 1st; (still a little insomnia --> usually less lying in bed, more sitting at the desk)
Article Directory
foreword
C language, one day of simple modification, making of address;
1. Coding experience skills
- When modifying the content, it is very important to use quick modification to prevent modification errors. It is beneficial to reduce the error rate, learn to use skills, and do not use brute force;
- Make an effective log and modify the code step by step;
- Once it needs to be modified, modify it early and don't delay it later, such as the merge of createTx this time, merge it early and don't modify it later;
2. Subtle details that make mistakes
1.ascii.decode() will generate an error if the value does not meet the conditions
Decodes the ASCII [bytes] (a list of unsigned 7-bit integers) to the corresponding string.
If [bytes] contains values that are not in the range 0 .. 127, the decoder will eventually throw a [FormatException].
so! The code needs to be accurate and easy to debug, and learn to debug code more conveniently.
import 'dart:convert';
String intListToXpubString(List<int> data) {
// 检查数据是否符合要求,因为是throw exception,所以catch捕捉不到,函数多细节考虑!
if (data.any((value) => value > 127)) {
return null;
}
try {
return ascii.decode(data);
} catch (e) {
return null;
}
}
2. When using the index of the list, be sure to check whether the length is appropriate
data.length>3 && data[3] == 'a'
3. The modification must use global modification to prevent mistakes and reduce spelling errors
In addition, according to the business flow, stability modification is also a good choice, retaining intuition, but improving stability;
4. Improve the ability to retrieve problems, find problems quickly and accurately, and output reasonable logs
reasonable log
Summarize
It is mainly a summary of recent mistakes and a summary of practice.