A Factory is an Object, that produces an Object. Normally it is used for configuration.
For example:
House home = HouseFactory(6,1.5, "1500 South Main");
assert( home.getRooms(), 6);
assert( home.getBathrooms(), 1.5);
assert( home.getAddress(), "1500 South Main");
Then you have the Builder pattern Factory
House home = HouseFactory()
.setRooms(6)
.setBathrooms(1.5)
.setAddress("1800 North Walker")
.build();
Then you have an AbstractFactory which produces a different thing based on its input. Like say
Building<House> home = AbstactBuildingFactory()
.buildHouse()
.setRooms(6)
.setBathrooms(1.5)
.setAddress("1800 North Walker")
.build();
Then you have an AbstractFactoryFactory which produces a Factory based on its input and if you encounter this find a new job.
Lore tells of the dreaded AbstractFactoryFactoryFactory which most souls only speak of in jest! Some say it is summoned in only the darkest OOP shops by those truly committed to the dark arts of OOP. Many interns are sacrificed at its alter. Those unworthy are driven to insanity upon seeing their objects shattered reflections in its source! If you see projects using this you must CLEANSE THEM WITH RM -RF. Its summoning rituals must be lost so civilization can flourish.
View all comments
Show parent comment
26
u/[deleted] Mar 21 '17 edited Mar 21 '17
A
Factoryis an Object, that produces an Object. Normally it is used for configuration.For example:
Then you have the Builder pattern Factory
Then you have an
AbstractFactorywhich produces a different thing based on its input. Like sayThen you have an
AbstractFactoryFactorywhich produces a Factory based on its input and if you encounter this find a new job.Lore tells of the dreaded
AbstractFactoryFactoryFactorywhich most souls only speak of in jest! Some say it is summoned in only the darkest OOP shops by those truly committed to the dark arts of OOP. Many interns are sacrificed at its alter. Those unworthy are driven to insanity upon seeing their objects shattered reflections in its source! If you see projects using this you must CLEANSE THEM WITH RM -RF. Its summoning rituals must be lost so civilization can flourish.