Search code examples
javapojo

What is the difference between field, variable, attribute, and property in Java POJOs?


When referring to internal private variables of Java POJOs that have getters/setters, I've used the following terms:

  • field
  • variable
  • attribute
  • property

Is there any difference between the above? If so, what is the correct term to use? Is there a different term to use when this entity is persisted?


Solution

  • From here: http://docs.oracle.com/javase/tutorial/information/glossary.html


    • field

      • A data member of a class. Unless specified otherwise, a field is not static.

    • property

      • Characteristics of an object that users can set, such as the color of a window.

    • attribute

      • Not listed in the above glossary

    • variable

      • An item of data named by an identifier. Each variable has a type, such as int or Object, and a scope. See also class variable, instance variable, local variable.