노무현 대통령 배너

Operation과 Method의 차이

Work & Study/TechTalk 2007/02/20 16:45 posted by k16wire

우리가 흔히 혼용해서 사용하는 용어중에 Operation과 Method가 있다. 둘은 어떻게 다른걸까 ? 마틴파울러가 쓴 UML 입문서 ‘UML Distiled’에 보면 아래와 같은 내용이 나온다.

“An operation is something that is invoked on an object-the procedure declaration-whereas a method is the body of a procedure. The two are different when you have polymorphism. If you have a supertype with three subtypes, each of which overrides the supertypes’s getPrice operation, you have on operation and four methods that implement it.”

오퍼레이션과 메소드의 차이를 다형성에 비추어 그 차이를 이야기 하자면 하나의 오퍼레이션이 여러개의 메소드를 구현될수 있다. 예를 들어보자. getPrice라는 오퍼레이션은 상속을 통해서 하위 클래스에서 override될수 있기 때문에 여러개의 메소드로 구현되는 형태가 된다고 할수 있다.

사실 두가지 용어를 혼용해서 쓰는게 일반적이며 둘을 엄격하게 구분하자면 오퍼레이션은 클래스의 동적인 특징을 개념적으로 정의해 놓은것이며, 메소드는 이를 구체화 시켜서 정의한것이다.

크리에이티브 커먼즈 라이선스
Creative Commons License