The Builder pattern is useful for creating complex objects that have multiple fields, some of which may be optional. Instead of relying on long or overloaded constructors, the Builder pattern lets you construct an object step by step and produce a fully initialized instance at the end. This chapter explains this pattern using multiple examples.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Builder Pattern

  • Vaskaran Sarcar

摘要

The Builder pattern is useful for creating complex objects that have multiple fields, some of which may be optional. Instead of relying on long or overloaded constructors, the Builder pattern lets you construct an object step by step and produce a fully initialized instance at the end. This chapter explains this pattern using multiple examples.