Search code examples
oopterminology

Umbrella term for attributes, methods and properties?


Object oriented programming uses these terms for similar concepts:

attribute: variable associated with an object   (apparently also called field)

method: function associated with an object

property: calculated like a method without arguments, but accessed like an attribute

class Person(object):

    def __init__(self, name, birthday):
        self.name = name
        self.birthday = birthday
    
    def age(self, day):
        return day - self.birthday

    @property
    def astrological_sign(self):
        return some_magic(self.birthday)

The code above illustrates their use in a Python class.

Is there any way to say "attribute, method, or property" in one word?

(I am rather annoyed that they took the word property for something specific.
They should have left it generic, and used metribute instead.)


Solution

  • In general, there's little unambiguous, universally accepted terminology in programming. What may be called one thing in one context may be called something else in another.

    Likewise, a simple term may have one meaning in one context, but another meaning in another. The term property is actually a good example of that, since it means something completely different in the context of property-based testing.

    That said, however, FWIW, in .NET the collective term for all of these is member.

    I haven't, however seen that terminology used in e.g. the Java community.