Finally, let's talk aboutCodeStyle issues
1. Magic numbers, also known as numerical Constants
In short, there is a digital stamp, and no one knows what this means. This kind of code also causes a problem when the value of the code changes, it cannot be ensured that all relevant code is modified.
There are too many such cases in openwnn, so I will not list them one by one.
The same String constant is also a problem.
Defining constants in this case is not the only way to solve the problem. There are still many better methods, such as splitting categories.
2. Static table
Static block static {} in Java code can execute some fixed value assignment code in advance. However, if this feature is not used properly, it will become a problem in code.
In the romkan codeRomkantable indicates how the entered English letters are converted into Kana.
But after the code is written, it will be crowded together. And the related code is particularly long.
If the conversion code is put in XML, it is much better to load it at startup. In addition, Java imposes restrictions on the code length. If you want to write pinyin into Chinese characters in the same way, the compilation will fail.
The same problem occurs in the turbidity table, semi-Turbidity table, and keyboard switching table.
3. Unicode code
Defasoftsoftkeyboard has a lot of Unicode-written code "\ u3044". Who knows what it means?
These unicode can be stored as real characters in XML files for ease of understanding.
4. Empty catch
Catch must not be empty. If it must be empty, write a comment. In catch, only logs are printed and treated as null.
This is also common in openwnn.