Creator
Problem:
Who should be responsible for creating a new instance of some class?
其實這和上次提到的information expert 有點類似,都是在探討責任歸屬
只是說Creator 要更細的去討論說,誰應該負責去把某個class 的 instance 建出來
那Larman有提出下面的解法
Solution:
Assign class B the responsibility to create an instance of class A if one of these is true:
● B "contains" or compositely aggregates A.
● B records A
● B closely uses A
● B has the initializing data for A that will be passed to A when it is created. Thus B is an Expert with
respect to creating A .
參考:
[1] Applying UML and Patterns,Third Edition,Craig Larman
GRASP Pattern- Information Expert
文章標籤
全站熱搜
留言列表