이제 리포지터리와 프록시의 책임을 정의할 수 있다. 다음 예제에서 CommentRepository 인터페이스 정의를 볼 수 있다. 이 인터페이스로 정의된 계약은 CommentService 객체가 사용 사례를 구현하는 데 필요한 storeComment(Comment comment) 메서드를 선언한다. 이 인터페이스와 이를 구현하는 클래스는 프로젝트의 리포지터리 패키지에 저장한다.
예제 4-2 CommentRepository 인터페이스 정의하기
public interface CommentRepository {
void storeComment(Comment comment);
}