IDE를 사용할 경우 자동으로 override 메소드를 만들어주곤 한다. 이때마다, 자동으로
@Override
public void test() {
// TODO Auto-generated method stub
}
와 같은 주석이 생긴다.
항상 그냥 넘어갔지만 'stub'이라는 단어를 몰라, 갑자기 무슨 뜻인지 궁금해져서 알아보게 되었다.
https://stackoverflow.com/questions/9712810/what-does-todo-auto-generated-method-stub-mean 스택오버플로우 글을 보면,
It means that your IDE (or some other tool) has automatically generated a method for you, but has left the body blank to be filled in by you (this is known as a "stub").
라는 답변이 달려있다.
IDE에서 자동으로 나를 위해 메소드를 만들어줬다는 뜻이고 body blank는 내가 채워야 된다는 뜻이다. 내가 채워야 하는 body blank가 stub 이라는 것이다!
A method stub is a short and simple placeholder for a method that is not yet written for production needs. Generally, a method stub contains just enough code to allow it to be used – a declaration with any parameters, and if applicable, a return value.
위키를 보면 간단하게 Method stub이란 아직 작성되지 않은 메소드에 대한 place holder라고 말을 한다.
근데 생각해보니까 placeholder가 뭔지 모른다; (아제발)
In computer programming, a placeholder is a character, word, or string of characters that temporarily takes the place of the final data. For example, a programmer may know that she needs a certain number of values or variables but doesn't yet know what to input. She can use a placeholder as a temporary solution until a proper value or variable can be assigned.
A placeholder in programming code may also indicate where specific code needs to be added, but the programmer has not yet written the code. The placeholder reminds the programmer where to add code or can let other programmers know that additional code still needs to be added in general.
Placeholders may also be commented out to prevent the computer program from executing part of the code.
라고 하는데 (출처: https://www.computerhope.com/jargon/p/plactext.htm)
즉, placeholder란 빈 값으로 미래의 값을 대체하는 부분이라는 것이다. placeholder를 통해 프로그래머가 구현해야할 코드의 위치나 추가해야한다는 사실 자체를 알려줄 수 있다.
stub 자체가 미래의 값을 대신해준다는 의미가 있어 컴퓨터 관련해서 되게 많이 쓰는 용어라고 알고 있다. 현재 게시물에서는 method stub에 대해 다뤄보았지만 이외에도 API stub, stub module, linux libaray stub 등 다양한 곳에서 사용된다. 상황에 따라 다른 의미를 담고 있겠지만, 중심 의미는 비슷하다.
이를 알고 있기 때문에 다른 상황에서 이 용어를 만났을 때 더 효과적으로 대처할 수 있을 것 같다!