'RoleInterface'에 해당되는 글 1건

  1. 2006/12/24 Role Interface (9)

2006/12/24 11:37 Developer

Role Interface

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

Posted by ologist
이전버튼 1 이전버튼

블로그 이미지
ologist

공지사항

Yesterday171
Today52
Total34,795

달력

 « |  » 2012.02
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

최근에 받은 트랙백

글 보관함