Java programming Specification-Other specifications

Source: Internet
Author: User
Tags logical operators

1. "Force" when using regular expressions, the use of its pre-compilation function, can effectively speed up the regular matching speed.
Description: Do not define in the method body: Pattern pattern = pattern.compile (rule);


2. When "force" velocity calls the properties of the Pojo class, it is recommended to use the property name value directly, and the template engine automatically presses
The specification calls Pojo's getXxx (), if it is a Boolean base data type variable (the Boolean name does not need to be
prefix), the Isxxx () method is called automatically.
Description: Note that if it is a Boolean wrapper class object, the GetXxx () method is called first.


3. "Force" the variables sent to the page in the background must be added $! {var}--an exclamation point in the middle.}
Description: If Var=null is not present, then ${var} will be displayed directly on the page.


4. "Force" note math.random () This method returns a double type, noting the range of values 0≤x<1 (capable
Take the zero value, note that except for the 0 exception), if you want to get a random number of type Integer, do not enlarge X by 10 times and then
Rounding, directly using the Nextint or Nextlong method of the Random object.

5. "Force" gets the current number of milliseconds system.currenttimemillis (); Instead of the new Date (). GetTime ();
Note: If you want to obtain a more accurate nanosecond time value, use System.nanotime (). In JDK8, for statistical
Time and other scenarios, we recommend using the Instant class.


6. "Recommended" Try not to include variable declarations, logical operators in the VM, or add any complex logic to the VM template.
Series.


7. "Recommended" the construction or initialization of any data structure should be specified in size to avoid unlimited growth in the data structure to eat up memory.


8. "Recommended" for "explicitly discontinued code and configuration" such as methods, variables, classes, configuration files, dynamic configuration properties
And so to be resolutely removed from the program, to avoid causing excessive rubbish.

Java Programming Specification-Other specifications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.