Wikipedia에서는 Information Hiding을 아래와 같이 설명한다.
In computer science, the principle of information hiding is the hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed. Protecting a design decision involves providing a stable interface which shields the remainder of the program from the implementation (the details that are most likely to change). In modern programming languages, the principle of information hiding manifests itself in a number of ways, including encapsulation (given the separation of concerns) and polymorphism.
정보 은닉(Information Hiding)은 컴퓨터 프로그램 내에서 변할 수 있는 설계 결정들(design decisions)을 숨기는 것으로, 설계 결정들이 변경되었을 때, 그 변화로부터 프로그램의 다른 부분들이 영향을 받지 않도록 하는 것이다. (역자 주> 이는 module 설계 시 이용되며 low-couping을 구현할 수 있다)
이러한 설계 결정을 보호하는 행위는, 구현들(변화 가능성이 있는 세부적인 내용들)로 부터 프로그램의 나머지 부분들을 숨겨주는 안정적인 인터페이스를 제공하는 것을 포함한다. 현대의 프로그래밍 언어에서는 캡슐화(encapsulation)와 다형성(polymorphism)을 포함하여 다양한 방법으로 정보 은닉의 원칙을 명시하고 있다.
cf) Information Hiding vs. Encapsulation
여기부터는 개인적인 의견이 대부분입니다. 편의상 한글과 영어 용어를 같이 사용합니다. (양해 바랍니다)
컴퓨터와 관련된 공부를 조금이라도 한 사람들이나, 객체지향 프로그래밍(Object-Oriented Programming)을 조금이라도 해 본 사람들에게 Information Hiding과 Encapsulation을 설명하라고 하면 다소 머뭇거리는 사람들이 있다. 이 글을 읽고나면 쉽게 설명할 수 있으리라 믿는다. (내가 잘못 알고 있지 않다면...)
Information Hiding은 위에서 설명한 것과 마찬가지로, 원칙(principle)이다. 즉, 개념적이고 논리적인 것이 바로 information hiding이며, 한 module내에서 변화할 수 있는 design decisions를 다른 부분들로부터 숨기는 원칙/원리를 의미한다.
Encapsulation은 information hiding을 구현(실제화)하는 것으로 생각할 수 있다. 위에 wikipedia에서 설명한 내용을 참고하면, 많은 프로그래밍 언어들(c++, java 등)이 information hiding을 위해서 다양한 방법들을 제공하는데, 그 중의 하나가 encapsulation이다. 하지만, encapsulatio은 적용 시에 관심분리(separation of concerns)가 선행되어야 한다. 이 말이 무슨말이냐 하면, interface처럼 외부에 보여질 것들과, module내로 숨길 정보들(design decisions, imlementation details)을 분리하여야 한다는 말이다.
즉, 두 용어가 사실은 같은 개념을 내포하고 있으며, 우리가 보는 관점이 다를 뿐이다. 원리/원칙의 관점과 그 것의 구현 관점이라는 측면에서...
이올린에 북마크하기