In our development process, some code is often repeated and is necessary, such as singleton mode, observer mode.
Repeat and repeat every time.
So how do we improve our efficiency?
Keep in mind that we are using the IDE, not a text editor. Use the tools and do more!
Let's write some of this today. How to quickly write a code template for a single sample. Then make up the observer and other ... The parameters are then described individually.
Click Windows-preferences-java-editor-templates in 1.Eclipse to go to the specific Settings page.
2. Click New to open the template window
3. Enter this template name in the name input box, which is named: Instance
4. In description Add a description of the template (not required), the personal side is filled with: non-thread-safe single case
5. Add the template code to the pattern, the following is a singleton
Private Static ${enclosing_type} sinstance; Private ${enclosing_type} () {} Public Static ${enclosing_type} getinstance () { ifnull) { new $ {Enclosing_type} (); } return sinstance;}
Note: Enclosing_type represents the class name
OK, configure the above template. The next use is simple!
1. Create a new class.
2. Press alt+/in the class and select instance.
0 seconds to write a single case!
More efficient development, waiting for everyone to explore together!
Eclipse Code Templates build quickly