Builder and Abstract Factory have meant for different purposes. Depending on right use case, you have to select suitable design pattern.
Builder salient features:
- Builder pattern builds a complex object using simple objects and using a step by step approach
- A Builder class builds the final object step by step. This builder is independent of other objects
- Replacement to Factory method/Abstract Factory in this scenario : Too Many arguments to pass from client program to the Factory class that can be error prone
- Some of the parameters might be optional unlike in Factory which forces to send all parameters
Factory (simple Factory) salient features:
- Creational pattern
- Based on inheritance
- Factory returns a Factory Method (interface) which in turn returns Concrete Object
- You can substitute new Concrete Objects for interface and client (caller) should not be aware of all concrete implementations
- Client always access interface only and you can hide object creation details in Factory method.
Often, designs start out using Factory Method (less complicated, more customizable, subclasses proliferate) and evolve toward Abstract Factory, Prototype, or Builder (more flexible, more complex)
Have a look at related posts:
Keeping builder in separate class (fluent interface)
Design Patterns: Factory vs Factory method vs Abstract Factory
You can refer to below articles for more details:
sourcemaking
journaldev