Does the Builder pattern replace the factory pattern?

别说谁变了你拦得住时间么 提交于 2019-12-13 02:05:08

问题


I know this question is asked many times but I just want to clear more on this. Can a builder pattern replace factory pattern.

Yes Builder pattern create and return a complex object step by step and this can be done in factory pattern also.


回答1:


They are both Creational patterns. So, not replace, just an alternative that's appropriate under some conditions. The nature of patterns is that they present solutions to common problems, it's quite reasonable that subtly different problems have different solutions.

All discussed here, maybe it's more interesting if you tell us what you didn't understand or agree with about the answers here




回答2:


For more information on when to use the Builder Pattern and its advantages you should check out my post for another similar question here



来源:https://stackoverflow.com/questions/1258638/does-the-builder-pattern-replace-the-factory-pattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!