0
誰かが "属性"と "プロパティ"の間のニュアンスを慎重に記述できますか?私はそれらを時々交換可能に使用し、他人の差別化手段として使用することができます。クラス "属性"と "プロパティ"の違いは何ですか?
誰かが "属性"と "プロパティ"の間のニュアンスを慎重に記述できますか?私はそれらを時々交換可能に使用し、他人の差別化手段として使用することができます。クラス "属性"と "プロパティ"の違いは何ですか?
property
は、多くの場合、(python、C#、pascal、など)は、実際に取得/設定によって実装された「仮想属性」を記述するために使用されるがattribute
とproperty
用語は、ほとんどの場合(またmember
、field
)に同義語ですメソッド(および通常の属性にはattribute
が使用されます)。
例えば(のpython-のような擬似コード):ここで
class MyClass:
string first_name_attribute;
string last_name_attribute;
@property
def full_name(self):
"""Getter method returns the virtual "full name"."""
return self.first_name_attribute + " " + self.last_name_attribute
@full_name.setter
def full_name(self, string value):
"""Setter method sets the virtual "full name"."""
first_name, last_name = value.split(" ")
self.first_name_attribute = first_name
self.last_name_attribute = last_name
我々持っている二つの "本当の" 属性 - first_name_attribute
とlast_name_attribute
と "仮想" プロパティ - full_name
。