57 suggestions in objective Java

Source: Internet
Author: User
1. create and destroy objects

Article 1st: static factory methods should be used to replace Constructors

Article 2nd: using petroleum functions to enhance Singleton attributes

Article 3rd: Strengthen the non-instantiation capability through private constructor

Article 3: avoid repeated object Creation

... Example:

String S = new string ("silly"); // dont do this each execution creates a string instance

String S = "no longer silly ";

Article 3: Eliminate expired object references

Article 3: avoid using the final function

2. Common methods for all objects

Article 3: whether to comply with general conventions when modifying equals

Article 12: hashcode is always rewritten when equals is rewritten.

Article 3: always rewrite tostring

Article 3: clone with caution

Article 3: consider implementing the comparable Interface

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.