카테고리 없음

Diffrence between Property and Attribute

SciomageLAB 2024. 10. 4. 12:10
반응형

Property와 Attribute의 차이

사전적 의미에서

Property는 무엇의 속해 있는 것으로 속성을 의미한다. 반면에 Attribute는 속해있지 않으며 특성을 의미한다.

데이터베이스에서

Attribute은 DB에서 테이블의 컬럼들을 의미한다. field라고도 불린다.

데이터 사이언스에서

Attribute는 feature의 성격을 나타낸다. dimensions, features, variables, field라는 용어로도 쓰인다.
예를 들어 아래 테이블에서 Color가 이 테이블의 또는 데이터 오브젝트의 Attribute가 된다. 여기서 Color가 가질 수 있는 값 들이 Red, White 둘 뿐이라면 Color가 가질 수 있는 상태(state)는 두 가지이고 이때 Attribute Type은 Binary가 된다.
숫자면 Numeric Attribute, 종류면 Nominal, {Small, Medium, Large}처럼 순서가 있다면 Ordinal이 Type이 된다.

아래 참고문헌 1에 더욱 더 상세하게 설명이 되어있다.

NAME Color
Rose Red
White Rose White

파이썬에서(객체 지향에서)

self._value가 Attribute, def value(self)가 Property이다.


# create a class
class Example: 

    def __init__(self, value): 
        self._value = value 

    @property              
    def value(self): 
        return self._value 

    @value.setter 
    def value(self, value): 
        self._value = value 

    @value.deleter 
    def value(self): 
        del self._value 

C/C++에서

컴파일러게 컴파일 전 주는 옵션 같은 것으로 MS에는 #pragma같이 msvc컴파일러만 쓰는 옵션처럼 GCC에서만 쓰이는 확장이다.

C에서

__attribute__((packed))#pragma PACK(1)처럼 구조체정렬을 하라 라는 메시지를 컴파일러에게 넘겨주는 것이다.

typedef struct
{
    char *charector;
} __attribute__((packed)) Person;

C++에서

[[noreturn]] void foo()
{
    throw error; //OK
}

XML에서

Person이라는 객체에서 Charecter은 Person이라는 객체의 Property이고, favorite이 Attribute가 된다.

<Person>
  <Charecter favorite="Chocolate"/>
</Person>

HTML에서

Attribute는 정적인 속성을, Property는 DOM에서 동적인 속성을 의미한다.

참고 문헌

  1. 데이타란?
    *정리가 잘된 글이라서 전체적으로 읽어보면 좋다.

  2. Geeksforgeeks - Difference between attributes and properties in Python

반응형