The Builder wraps a product to extract out the steps of constructing. Constructing steps are optional, not all of the objects will have the same implementation.
build method to finalize the constructionIn implementation,
build() method just returns the instance. It emphasizes how a product is made (step-by-step)create(). It emphasizes which product is made (via polymorphism).Since the Builder doesn’t initialize the product strictly, two patterns can combine together (it is not about Factory Method wraps the Builder, it is about Builder and Factory Method are at the same level). (example in the following note)
✅ Single Responsibility Principle (SRP): The Builder only contains methods related to the target product.
⚠️ Open/Closed Principle (OCP): Builder is not open to be extended.
✅ Liskov Substitution Principle (LSP) / Interface Segregation Principle (ISP): The Builder only contains methods related to the target product.
✅ Dependency Inversion Principle (DIP): Builder depends on an Abstract Product.