Builder pattern สร้างอ็อบเจ็กต์ที่ซับซ้อนทีละขั้น โดยแยกการสร้างออกจากการแสดงผล มันมีประโยชน์เป็นพิเศษสำหรับอ็อบเจ็กต์ที่มี parameter หรือส่วนที่ไม่บังคับจำนวนมาก ทำให้การสร้างอ็อบเจ็กต์อ่านง่ายและยืดหยุ่นแทนที่จะเป็น constructor ที่เทอะทะ
ปัญหาที่ Builder แก้
Objects with MANY parameters (especially optional ones) lead to problems:
✗ huge constructors: new Pizza('large', true, false, true, 'thin', false, ...) →
unreadable (which boolean is what?); hard to use; error-prone
✗ many constructor overloads (telescoping constructors) → messy
→ Builder provides a clean, readable, step-by-step way to construct such objects.
