I believe that everyone has seen camels, hump is the logo of camels, hump is wavy, compared to the string in the computer language, is very similar. The strings in the programming language are mostly composed of uppercase mixed letters (here the digital understanding of lowercase letters), and there are certain specifications, such as the first letters, the first letters, the word underline, where we can understand the uppercase For hump, such a string also has a wavy structure. If we extract the uppercase letters in the original string (do not include numbers), this is also what the Camel Case rules say, form a new string, this is the original characters. String Camel Words (both uppercase letters). Camel Words is actually based on the abstract extract of a string information, here we translate Camel case translate Camel Word to camel words, accurately, should be a hump word, but I think the camel word seems to be It is better to listen, and as long as the camel is identified is a hump, it is easy to understand using the camel word, and the Camel Word is expanded under the IDEA (can contain lowercase letters and matching characters *, not just uppercase letters), here We will use camel word as Camel Words Chinese translation. Let's take a look at the specific conversion example:
String Name Correspondence Camel word UsermanagerumuserManagerImplumiGetUsernameinfouniuserbankaccountnumberban
Say these, let's take a look at the embodiment of this principle in Java's programming language. The name, class name, function name, and variable name in Java are all strings. The rules are also very obvious: class name requires the first letters, the package name, the function name and variable name should be the first letters lowercase, and these defaults. Rules, I believe this is more convenient and easy to understand the extraction of camel characters on the string. Moreover, the extracted camel word is also more reflecting the composition of the original string. Said so much, let us see how to use the camel word to simplify our code, here we will recommend Intellij Idea tools to you, which is also the best tool to support this feature.
Intellij Idea extends the camel word, allowing a blur match to enable lowercase letters (automatic matching to word ending) and "*" in Camel Words. Intellij Idea implements strict string first alphabet match (case-sensitive), so the information of the first letter is important, if you want to implement a prefix blur match, add "*" characters.
String Name Ide Idea Match UserManagerum, Uma, USMUSERMANAGERIMPLUMI, * MI, U * MGETUSERNAMEINFOGUNI, * UNIUSERBANKACCOUNUMBERUBAN, * BAN
With these rules, let's take a look at several specific applications.
1 Navigation for files or tags: In the encoding we sometimes open a file or locate the location specified by a file, such as the function declaration, class attribute declaration, etc. If you are positioned to the UserManager interface file, we only need to press CRTL N (Interface or Class File Location). Enter the UM in the input box, you can locate this Java interface file, and the same input UMI can be positioned to UserManagerImpl Java implements classes. If you are positioned to a function name or a variable name, we only need to press CRTL Alt Shift N (Identification Position), enter Guni or * UNI in the input box, you can locate the location of the GetUserNameInfo declaration, easy to enter uban Located to the UserbankAccountNumber property declaration. Since the function names and variable names in Java usually begin with lowercase letters, the IDEA requires a strict prefix match, so the function name or variable name positioning must start with the first letters (lowercase) or "*" Start, so that the camel is matched, otherwise you may not get the result you want. Also use file positioning CRTL SHIFT N simply two cases of CRTL N and CRTL SHIFT ALT N. Figure 1: Interface and class matching
Figure 2: Interface or class property match
2 Variable Name Tips: During the encoding process, we must declare a large number of variables, giving them a lot of variables, and wasting you a lot of time to think about a suitable name. Let's take a situation, when using a Velocity development package, we use a class velocityEngine, we want to instance this class, we are typing the class name plus space, then press CRTL SPACE (basic code completion function), you will find IDEA Give you a candidate variable name, which is also based on the variable name generated according to the hump matching principle, and the case is replaced. Here we choose "Engine" variable name, which is fully in line with our will. If you enter the lowercase form of a letter in the camel word, press CRTL SPACE, IdeA automatically completes the variable name (according to the selection of the next letter in the camel word), here if e, press CRTL Space, ENGINE is automatically complement. 3 Edit: We know that in Editor Options, we have such an attribute: Use 'Camelhumps' Words, if you select this option, IDEA will realize the word functionality of the string, which is also based on the principle of hump matching. Select this row configuration, which affects the cursor movement (CRTL Right / Left), select the word (CRTL W) at the cursor, delete characters to the first or word or word tail (Ctrl Backspace / delete), and the mouse double click, this Item features may be different, whether you choose this feature, please discrete your own experience. 4 Reconstruction: The reconstruction function of IDEA has excellent, how can you still need? Here is a technique that reconstructs renamed with camel words. Let us see such an example: You define an interface, name UserManagor, here you mistaken "Manager" as "managor", and you implement the interface, there are two classes: UserManagorHibernateImpl and UserManagorjdoImpl, in In the encoding, you have also selected Managor as the instance name of UsermanAgor based on the Camel word principles. In the project for a while, you find UserManagor spelling wrong, how to change? IDEA will give you a surprise, when you rename UserManagor as UserManager, IDEA will be asked if you would UserManagorHibernateImpl change UserManagerHibernateUtil, will UserManagorJdoImpl change UserManagerJdoImpl, Better, IDEA will also prompt you to change the variable name managor manager, All of this didn't think of it, camel words brought new ideas for reconstruction. Summary: Camel word in Intellij IDEA is mainly reflected in choice, prompt, and renaming, etc., skilled use of this feature is very convenient to your code development, in Idea5.0, will expand this Features in all aspects, you will experience more convenience.