Weekly -- JavaBean

Source: Internet
Author: User

Recently I wrote someCodeTo record some encoding rules for your use.

  • Each property must have a corresponding method for obtaining and setting properties, that is, each property must provide the corresponding getter and setter methods (simple method: select all variables-> right-click source-> Generate getters and setters-> select all --> OK ).
  • If a property is of the boolean type, the method for obtaining and setting the property is different. For example, a property of the boolean type is named, you must provide the corresponding methods for obtaining attributes, ISA () and Seta ().
  • All attributes are preferably private variables, that is, the attribute of each class should be set to private, and the values and operations of attributes should be carried out through corresponding methods.
  • It is best to set all methods to a common method, that is, all methods must be set to public, so that the external world can invoke the methods in the class.

PS: If the attribute name is XXX and it is not a Boolean variable, the values and settings of the corresponding attribute are getx ×× () and setx ×× (), the first letter in the method name should be capitalized. If the attribute name is isxx and it is a Boolean variable, the corresponding method is isxx (), and the value assignment method is setxx (), in this case, the method name and attribute name of the value method are the same, and the first letter of the Method Name of the value assignment method is capitalized.

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.