Oop terminology: difference between attributes and Properties

Source: Internet
Author: User
  • Source: http://www.wwwcoder.com/
  • By venkatarama uppugunduri

These are at least a confusing term in the programmer's world. Their meanings are often exchanged.

Here is my opinion on them.

Attributes discusses the nature of the topic. Properties discusses the property, content, status, or ownership of all things in the topic.

Let's say that I am a human. On this premise, humans are an attribute of my theme ). Just like there are people and dogs in my apartment, the people here are properties with the apartment as the theme ).

The same thing appears in the. NET world. For example, serializable is the attribute of an instance object, and the object may have an attribute that uses the expected true or false Boolean value to indicate that the object can be serialized. This will tell. net runtime: This class can express the serialization capability through attribute, and does not need to use the property exposed by it) the class is serializable.

Therefore, attribute defines the unique nature or nature of a topic, and property belongs to this topic. In the object-oriented example term, the attribute (feature) related to the subject should have the following meanings: "What is it", and the property (attribute) should have the following meanings: "what ".

Example
  • People are human beings. Here humans are an attribute ).
  • People have wings. The wings here are properties ).

What about field and property? Most of the time we will hear that fields and properties sometimes sound similar, and sometimes they sound different. In fact, fields (field) defines the areas required to store the value or topic status, while properties (attribute) not only presents the status or value, nothing else.

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.