Principles and Architecture / GRASP
Creator
Original notes by SunDiaL · View English source
Problem: Who creates object A?
Solution: In general, Assign class B the responsibility to create object A if one, or preferably more, of the following apply:
- Instances of
Bcontain or compositely aggregate instances ofA - Instances of
Brecord instances ofA - Instances of
Bclosely use instances ofA - Instances of
Bhave the initializing information for instances ofAand pass it on creation.