Comparing factory and builder patterns
The factory pattern and the builder pattern have a similar goal and may be confused if they are not properly understood. Both patterns allow to create objects, but each one has its own peculiarity and scope of application.
In particular, the factory pattern focuses on object creation on the basis of a category or other ways to group objects. When a client asks an object to a factory, it specifies the category of object it needs. However, all objects created by the factory implement the same interface or inherit from the same object so that the client can manage them in the same way without actually knowing its real type.
The builder pattern focuses on building complex objects. Unlike the factories, the builders of the builder pattern do not always return the same type of object. They may return (and it happens often) different type of objects. Consider a document converter—it returns different types of objects based on the requested output format.
Moreover...