It's just like Information Expert, but he says that calling a class constructor = calling a method
"Who" should call for create class instance ?
Assign class B the responsibility of creating other objects of class A
It is logical to use the pattern if class B uses, aggregates class A
Using this pattern does not increase cohesion, since the created class is usually only visible to the creator class.
If the procedure for creating an object is quite complicated (for example: it is performed on the basis of some external condition), it is logical to use the pattern: "Abstract Factory", that is, to delegate the responsibility of creating objects to special classes
So, if a Check creates a Product, then it calls it; If the Calculator creates a Check, then it calls it; Sounds simple, but you have to learn how to produce/construct objects for business with this, i.e. what we saw in "Information Expert" when everything is called through new, and this pattern teaches that a constructor call is the same as a method call, because you will agree, it will not be nice to see this piece somewhere at the other end of the system?:
new Calculator([new Check(new Product("hamburger", 200), 2)], 45).toFixed(2); // 220.00How about shortening it to this:
new Calculator(45).getProductSumm(2, "hamburger", 200).toFixed(2); // 220.00Is that better, yeah ?