To do a good job, he must sharpen his tools. If you want to improve the efficiency of programming development, you must choose a handy development tool.
JetBrains offers a range of powerful, unified development tools that developers love. IDEA is a professional IDE (integrated development environment) for Java development. More than 90% of enterprises use IDEA for Java development instead of other tools such as Eclipse.
However, to maximize development efficiency, it is not enough to have a good development tool, but to be able to use it proficiently. For new users of IDEA, such a feature-rich development tool can be confusing, but they don’t want to take the time to learn how to use it, so they just think of it as a notepad that can write code.
Fish skin for everyone to summarize their own master IDEA using skills, including practical plug-ins, development skills and reading source skills. Just 5 minutes of reading can increase development productivity tenfold!
What, you said IDEA is too expensive? If you are a student party, you can use the full range of IDEA and JetBrains products for free
Address: www.jetbrains.com/shop/eform/…
quick key
To improve the efficiency of developing and reading source code with any IDE (integrated development environment), the first step is to use keyboard shortcuts.
In IDEA, you can query and set shortcut keys in the Keymap setting of Preferences, as shown in the figure below:
Practical plug-in
1. Key Promoter X
Hotkey prompt plug-in. When you perform a mouse operation, if the operation can be replaced by a shortcut key, it will give you a prompt to help you naturally form the habit of using shortcut keys, instead of rote memorization.
Address: plugins.jetbrains.com/plugin/9792…
2. AiXcoder Code Completer
Code prompts to complete the plug-in. AI is used to automatically prompt and complete the code, which is more intelligent than the code completion of IDEA.
Address: plugins.jetbrains.com/plugin/1357…
3. Arthas Idea
Arthas command generates plug-ins. Arthas is an open source Java diagnostics tool that automatically generates Arthas diagnostics for Java code without having to go to the official website.
Address: plugins.jetbrains.com/plugin/1358…
4. Auto filling Java call arguments
Code generation plug-in. Automatic completion of function call parameters by shortcut keys, useful for constructors and methods that contain a lot of parameters!
Address: plugins.jetbrains.com/plugin/8638…
5. GenerateAllSetter
Code generation plug-in. One-click generation of all set method calls for a given object, automatic assignment, or generation of the return value of a method, which is useful when unit testing fake data.
Address: plugins.jetbrains.com/plugin/9360…
6. GenerateSerialVersionUID
Code generation plug-in. One-click generation of SerialVersionUID for a class that implements the Serializable interface.
Address: plugins.jetbrains.com/plugin/185-…
7. GsonFormat
Code generation plug-in. When used in a class, pasting a piece of Json text automatically generates the nested structure code for the object.
Address: plugins.jetbrains.com/plugin/7654…
8. Lombok
Code generation plug-in. Using Lombok dependencies and annotations can greatly reduce the amount of code required for POJOs (simple, old-fashioned Java objects).
After installing the plug-in, you also need to enable annotation support, which can be configured in this article: www.baeldung.com/lombok-ide…
Plug-in address: plugins.jetbrains.com/plugin/6317…
9. Rainbow Brackets
Code browsing plug-in. Color-coded brackets nesting hierarchies make it easier to read and locate and adjust error code faster. However, it is recommended not to have a lot of nesting in the code!
Address: plugins.jetbrains.com/plugin/1008…
10. CodeGlance
Code browse minimap plug-in. Generate a code minimap on the right side of the editor. You can drag and drop the small map cursor to quickly locate the code, which is very useful when reading code files with many lines.
Address: plugins.jetbrains.com/plugin/7275…
11. GitToolBox
Git enhancement plug-in. On top of its own Git function, it has added functions such as checking Git status, automatically pulling code, and submitting notification. Best of all, you can see the last commit for each line of code.
Address: plugins.jetbrains.com/plugin/7499…
12. Translation
Translation plug-in. The most painful thing for programmers is to encounter English words they don’t understand when reading code. With this plug-in, text can be automatically translated into multiple languages by right clicking with the mouse.
Address: plugins.jetbrains.com/plugin/8579…
Development skills
Plug-ins can add new functions to IDEA, but IDEA is also very powerful, with many practical development skills.
- Use the code above to generate and browse plug-ins
2. Familiar with shortcut keys through the Key Promoter X plug-in.
There are so many shortcut keys on the Internet that I won’t repeat them here. The most commonly used shortcut keys are newline, copy/delete the current line, and code formatting.
3. Quickly generate code for classes using shortcut keys (Win: Alt+Insert, Mac: Command + n)
4. Live Templates
Code template is a very useful function in IDEA. It can generate specified code segments by abbreviations (keywords). Many duplicate codes can be quickly generated in this way, which improves efficiency and reduces the probability of errors.
The following is an example:
IDEA has many code templates built in for us, such as main:
You can also define your own abbreviations and code snippets to generate:
You can also use predefined variables, custom variables, and built-in functions.
5. Use the built-in clipboard to save the replication history
The essential skill of writing code is copy and paste, which not only improves efficiency, but also reduces error rates (such as users, secret keys, addresses, etc.).
IDEA has a built-in clipboard to help us save the history of the copy. Press Shift + CTRL + V to select the copy when pasting.
Not content with a built-in clipboard? You can also use more advanced software: Ditto (Windows) or Alfred (Mac)
6. Use built-in Git
IDEA has built-in Git assistant tools, which can visualize branch management/switch, code submission/update/conflict resolution/rollback, code history version view, etc. You can view all the features from the top menu VCS > Git:
Git logs can be viewed in the bottom bar:
7. Use the built-in HTTP Client to test the interface
No longer need to use external interface testing tools such as Postman, IDEA has a built-in HTTP Client, which can be called by writing request scripts, which is very flexible. Open it in Tools > HTTP Client from the top menu:
Write scripts to test HTTP interfaces:
Detailed usage, please read the official document, address: www.jetbrains.com/help/idea/h…
Reading source code tips
Good programmers read a lot of source code, and there are a lot of tricks to reading source code.
In general, look at the whole (catalog and class diagrams) and then the parts (classes and functions), based on project documents summarized by others. For A Java project, it is necessary to look at the hierarchy of the package, then analyze the relationships among the classes (interfaces) in the package, including inheritance, implementation, delegation, method invocation, and finally look at the concrete implementation of a specific class’s properties and methods.
IDEA for the whole process of reading source code provides a series of easy to use function support, can greatly improve the reading efficiency.
1. File/class search
Search files/classes by filename
Shortcut key: Shift + Shift (double press)
2. Field search
Search by file content, can directly locate the target content location, support local (current file or selected code segment) and global search (project/module/directory/scope, etc.)
Local search shortcut keys: Win: Ctrl + F Mac: Command + F
Global search shortcut keys: Win: Ctrl + Shift + F Mac: Command + Shift + F
3. Go to the previous/next cursor position
When viewing source code, you often need to jump back and forth between two classes, which makes this feature quite useful!
To view the last cursor position, run the following Command: Win: Alt + ← Mac: Option + Command + ←
To view the next cursor position, use the following shortcut keys: Win: Alt + → Mac: Option + Command + →
4. View the implementation class of the interface (or the implementation of the interface method)
If the cursor selects an interface method, it jumps directly to the concrete implementation of that method. If there are multiple implementations, you can choose to jump to the specified implementation class.
Shortcut keys: Win: Ctrl + Alt + B Mac: Option + Command + B
5. View the method call tree
You can view all callers and callees of a given method.
Shortcut keys: Win: Ctrl + Alt + H Mac: Control + Option + H
6. View the class diagram
Very practical function, intuitive and clear display of the relationship between classes, easy to analyze.
Shortcut keys: Win: Ctrl + Alt + U Mac: Shift + Option + Command + U
7. View the inheritance tree of the class
The ability to view the parent and subclass inheritance relationship of a class. Shortcut keys: Win: Ctrl + H Mac: Control + H
8. See where defined variables are declared/called
If the cursor is at the variable declaration, view the code that uses that variable; If the cursor is at the used variable, view the declared position of the variable.
Shortcut keys: Win: Ctrl + B Mac: Command + B or press Ctrl/Command and click the left mouse button
9. See where the defined variable is called
Function is similar to the above function, only view the location of the variable call.
Shortcut keys: Win: Ctrl + Alt + F7 Mac: Option + Command + F7
10. Look at the structure of the class
The ability to view a class’s properties, fields, methods, inherited methods, anonymous classes, Lambdas, and quickly jump to a specified location.
Shortcut keys: Win: Alt + 7 Mac: Command + 7
11. View submission information for each line of code (subject to Git management)
Right click on Annotate in the code line list to enable code submission information:
The result is as follows, the bad code culprit quickly revealed!
The following articles are from programmer Fishskin and author Fishskin