개념적 무결성
-
오브젝트 6 - 다형성, 서브타이핑, 일관된 협력책책책 책을 읽읍시다/프로그래밍 2023. 2. 14. 23:29
다형성 다형성의 의미와 종류 다형성(polymorphism)이라는 단어는 그리스어에서 '많은'을 의미하는 'poly'와 '형태'를 의미하는 'morph'의 합성어로 '많은 형태를 가질 수 있는 능력'을 의미한다. 컴퓨터 과학에서는 다형성을 하나의 추상 인터페이스에 대해 코드를 작성하고 이 추상 인터페이스에 대해 서로 다른 구현을 연결할 수 있는 능력으로 정의한다[Czanecki00]. 간단하게 말해서 다형성은 여러 타입을 대상으로 동작할 수 있는 코드를 작성할 수 있는 방법이라고 할 수 있다. 객체지향 프로그래밍에서 사용되는 다형성은 아래와 같이 4가지로 분류할 수 있다. 유니버설(Universal 매개변수(Parametric) : 제네릭 프로그래밍과 관련이 높은데 클래스의 인스턴스 변수나 메서드의 메개..