The lecture on object creation, ADAP C09 (edition of winter 2021/22), contained a simple evaluation scheme for comparing different object creation patterns. The scheme was perhaps too simple, and I improved it. The basic three dimensions of comparing the patters are now:
- Ease of reading
- Easy of changing (in place)
- Easy of extending (without changing)
Code is easy to read, if all object creation takes place in the same method; it is normal(ly difficult) if you have to traverse the class hierarchy e.g. look into a subclass; it is hardest if you have to jump to another class.
If you have the source code and are willing to change it, code is easy to change if all relevant code is in one place (the same method), normal(ly difficult) if you have to touch two places, and hardest if you have to touch three or more places.
If you don’t have or don’t want to touch the source code but rather want to extend the pattern’s application in a non-invasive way, code is easy to extend if you can reconfigure it from a client class, normal(ly difficult) if you have to create a subclass, and impossible if you can only change the code in place.
I don’t think this is a great evaluation scheme. Most notably, extension and configuration don’t seem to be cleanly separated. Alas, it is the best I have for now.