In my course, I have been taught that, in general, In general, a class B should be responsible for creating instances of class A if one, or preferably more, of the following apply:
- Instances of B contain or compositely aggregate instances of A
- Instances of B record instances of A
- Instances of B closely use instances of A
- Instances of B have the initializing information for instances of A and pass it on creation.
And in some more complex cases, the best place to create an object is within a factory class.
My course has never taught me who should be responsible for deleting an instance. Say you want to delete an instance of A that has been created in an instance of B. Who deletes A? Is it A itself? Is it B? Is it some other class C that has a sole responsibility of deleting A?