To improve code readability, I first published the book "clean code. You can also refer to Java programming specifications. Improving code readability can directly improve the maintainability of the system. If there is any benefit in abstraction that does nothing, at least it improves the readability of the Code. To do one thing, do it well. Build a consistent naming style for yourself, so stay away from naming troubles!
Encouragement:
1. Multi-query dictionaries, use words or phrases with clear meanings, and use well-known and easy-to-understand words. For example, elapsedtimeindays is clearer than days. Don't be afraid of long strings. The current editor basically has the auto-complementing function, but it won't be as troublesome as you think. At the same time, don't avoid English. If you don't want to learn English, you 'd better not enter this line.
2. Use words that express intent and functionality. This is because the current software development is still "functional-oriented" and every name should try its best to express intent. For example, bufferedreader stdinreader instead of bufferedreader bufreader.
3. Use conventional vocabulary. For example, I, J, and K are used as the counts of cyclic variables, stdin is input, stdout is output, and stderr is error.
4. It is best to match the function name with the parameter to fully express the intent. For example, print (itemitem), instead of printitem (item), because there is a semantic repetition.
5. Make a meaningful distinction when expressing concepts and things. For example, words such as data and info are difficult to differentiate meanings, while indexes and ELEM are easy to differentiate.
6. Use the words that have been read. For example, tcpservport, rather than TSP;
7. The names of similar functions must be differentiated. Such as insert and fastinsert;
8. The name length should correspond to the scope. The larger the scope, the longer the name.
9. Class names use nouns or noun phrases; method names use verbs or verb phrases.
10. Each concept corresponds to a word and a consistent naming style is established. Don't get it for a while, obtain for a while, fetch for a while, and grasp for a while.
11. The appropriate shorthand. For example, how does firstkthmax compare with FKM?
12. Add a meaningful context. For example, servport is clearer than num context; arrlen is more contextual than N; addrfirstname is clearer than firstname context.
13. For the technical field, use the terminology in the computer field. For example, partition technology partition; binary search; patt;
14. For the business field, try to use words that are easy to understand and use domain terms when necessary. Each field has its own set of terminology, which can be easily found online. For example, in the financial software field, salary and wage fields are well-known domain terms.
Form:
A. You can use the upper or lower case of the first letter (I prefer) or underline.
B. All words in the package name or namespace are in lower case and separated by DOTS (if allowed ).
C. the first letter of each word contained in the class name is in upper case. The variable name or method name is not in upper case except the first letter of a word. We recommend the book Java programming style.
Avoid:
1. Avoid embedding types in names. For example, the account set uses accounts instead of accountlist, unless it is emphasized that this is a list type, because it conflicts with Java list, rather than being expressed as a list.
2. Avoid embedding meaningless prefixes or suffixes; for example, m_days
3. Avoid meaningless context. For example, I will use mysqrt as the function name.
4. Try to avoid shorthand for just a few characters. Programmers like to use abbreviations. For example, I sometimes use CNT as the shorthand for count. But the former is definitely not easy to spell. In short, you have to spell it by character.
5. Avoid slang and other words that require cultural background.
6. Avoid hiding nuances in long names. For example, insertforcomemploy and insertforvipemploy
Optional Vocabulary:
1. General Vocabulary:
Verb:
Set; get; Boolean judge isxxx/hasxxx; Add add/addall; insert; delete/deleteall; remove; update; store;
Load; refresh; access; select; sort; find/findall; search; replace; show; copy;
Check; locate; print Print; test; fix; complete completion; open; close; read readfrom; write writeto;
Undo; Edit edit; Create; save; Save As saveas; import; export; clear; Start startup; close shutdown;
Call call; execute exec; run; reset; cancel; Assert; shift; cleanup; build; generate;
Generate produce; reverse; Connect to append; assist; filter; transmit transfer; Split/divide; accept; rotate;
Compare compareto; differential diff; format; ignore trim; extract; Convert convert; Skip skip; view watch; match; transform;
Activate/invalidate [de] Activate; hide; navigation nav; declare declear; reference refer; Apply apply; equals; iterate iterator; string indicates tostring;
Extended extend/expand; implement; convert value valueof; create new XXX newxxx (newprime); Include contain; adjust; switch;
Change; initialize Init; action do; destroy; Service; clear dispose; Request request; Response response;
Notify notify y; wait for wait; distribute dispatch; record log; warn; error err; severe; fatal error fatalerr
Get next; get previous Prev; get first; get last; get subxxx (substring); get subscript indexof;
Get the object where the subscript is located xxxat; execute the action perform; event occurrence [noun] [verb] Ed (keypressed); trigger call invoke; Focus on focus; Retain retain;
Send; receive/Recv; obtain available; Verify validate; parse; Enable enable; Disable disable; exit;
Terms:
Random rand; vector; array; container or collection; queue; common; element ELEM; subscript index;
Source SRC; Target DEST; Task task; test Tester; Region region; range; position Pos; tuples tuple; row; column row;
Cell cell; Table table; record; Max; min; AVG/mean; count; previous Prev; next; current curr;
ID; DESC description; item/entry; header; tail; middle mid; left; right; front; Rear rear;
Buffer Buf; size; length Len; type/class; Name; full name qualifiedname; default; comparator;
Variable VAR; function func; field; value; accessors visitor; generator; iterator ITER; factory; level;
Driver; Manager; Controller; processor handler; Environment env; demo; event; date;
Placeholder holder; template type <t>; root Root; start/begin; end; Path; command; utility utils;
Child child; parent; problem; solution SOL/solution; specific implementation impl; usage; Option option; Capacity; limit;
Others:
Unsupported unsupported; recursive rec/recursive; General generic; Global; Local local; expected; Actual actual;
[To be continued]