Imagine a builder as an object that allows us to configure the object inside the builder that comes out at the end.
Imagine a factory as an interface with a create method and a type that comes out.
That's it, really.
If you need to combine the two,
$builder=newFactoryBuilder();$factory=$builder->installDieselEngines()// the factory will install diesel engines->installAutomaticTransmissions()// with automatic transmissions->build();// build the factory$car1=$factory->create();$car2=$factory->create();$anotherFactory=$builder->installPetrolEngines()// this factory will install petrol engines->installManualTransmissions()// with manual transmissions->addPerformancePackages()// and will produce sports cars->build();$sportsCar=$anotherFactory->create();
Please note that both factories should have the same interface (or be the same class), and the cars produced should have one too.
I will come back to you tomorrow, if it's not clear to you. I'm on a phone now. Let me know.
(I edited the answer for more explanation and legibility)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I believe your example is wrong.
Imagine a builder as an object that allows us to configure the object inside the builder that comes out at the end.
Imagine a factory as an interface with a create method and a type that comes out.
That's it, really.
If you need to combine the two,
Please note that both factories should have the same interface (or be the same class), and the cars produced should have one too.
I will come back to you tomorrow, if it's not clear to you. I'm on a phone now. Let me know.
(I edited the answer for more explanation and legibility)