Assign class B the responsibility to create an instance of class A if one or more of the following is true:
B aggregates A objects.
B contains A objects.
B records instances of A objects.
B closely uses A objects.
B has the initializing data that will be passed to A when it is created (thus B is an Expert with respect to creating A).
B is a creator of A objects.
If more than one option applies, prefer a class B which aggregates or contains class A.
Who should be responsible for creating a new instance of some class?
The creation of objects is one of the most common activities in an object-oriented system. Consequently, it is useful to have a general principle for the assignment of creation responsibilities. Assigned ...