Role Interface

2006/12/24 11:37
MF아저씨가 Role인터페이스를 좋아해서가 아니라, 난 사실 RoleInterface가 좋다.

On the whole I much prefer role interfaces, so I suggest pushing towards them as much as you can. There is work involved in doing it, but my belief has always been that you should only use interfaces when you really need substitutability, and if you do need interfaces you should think hard about what the consumer of that interface needs

내가 RoleInterface를 좋아하는 이유중의 하나는 SRP와 상관이 있다.

상대적으로 HeadInterface같은 경우는 아무래도 책임이 명확치 않은 Heavy한 클래스를 만들어질 위험이 더 많은 듯하다. 마치 procedural한 C Style과 유사하다.

적당한 책임을 가지고 있어야 할 클래스에 아무 생각없이 인터페이스를 추가를 하고 구현하는 일이 많기때문이다.

새로운 행위를 추가할 시점이 오면, 한번만 더 고민을 해서 적당한 곳에 위치를 해야만 좀더 깔끔한 코드를 유지할수 있을 것이다.

* HeadInterface

public interface Activity ...
  MfDate earliestStart();
  MfDate earliestFinish();
  MfDate latestFinish();
  MfDate latestStart();

class ActivityImpl...
  List<Activity> predecessors() ...
  List<Activity> successors() ...

* RoleInterface

public interface Successor {
  MfDate latestStart();
}
public interface Predecessor {
  MfDate earliestFinish();
}

class Activity
  List<Predecessor> predecessors() ...
  List<Successor> successors() ...


HeaderInterface
http://martinfowler.com/bliki/HeaderInterface.html


RoleInterface
http://martinfowler.com/bliki/RoleInterface.html

트랙백 보낼 주소 :: http://www.ologist.co.kr/trackback/467

댓글을 달아주세요:: 네티켓은 기본, 스팸은 사절

  1. 2008/05/23 05:17
    댓글 주소 수정/삭제 댓글
    뉴스를 위한 감사합니다…
  2. 2008/05/23 07:15
    댓글 주소 수정/삭제 댓글
    중대하고 유용한 위치!
  3. 2008/05/23 07:31
    댓글 주소 수정/삭제 댓글
    위치에 그것을 중대한 일은 좋아했다!
  4. 2008/05/23 07:39
    댓글 주소 수정/삭제 댓글
    그런 위치를 경이롭 위해 많게의 감사!
  5. 2008/05/24 01:13
    댓글 주소 수정/삭제 댓글
    여기 이것은 뉴스 있다!
  6. 2008/05/24 01:19
    댓글 주소 수정/삭제 댓글
    그런 위치를 경이롭 위해 많게의 감사!
  7. 2008/05/24 01:20
    댓글 주소 수정/삭제 댓글
    우수한 디자인!!
  8. 2008/05/24 01:30
    댓글 주소 수정/삭제 댓글
    아주 좋은 나는 위치 그것을 감사 좋아한다!
  9. 2008/05/24 02:53
    댓글 주소 수정/삭제 댓글
    아주 좋은 나는 위치 그것을 감사 좋아한다!


BLOG main image
OOP and Java by ologist

공지사항

카테고리

All (649)
private!! (106)
WEB & IT (140)
Developer (400)