[CS 문답] Builder 패턴이 무엇인가요?


[CS 문답] Builder 패턴이 무엇인가요?

빌더 패턴 예제 public class Cat { int size; int age; String name; private Cat(int size, int age, String name) { this.size = size; this.age = age; this.name = name; } public static class Builder { int size = 0; int age = 0; String name = null; public Builder setAge(int age) { this.age = age; return this; } public Builder setName(String name) { this.name = name; return this; } public Builder setSize(int size) { this.size = size; return this; } public Cat build() { return new Cat(size, age, name); } } } ...



원문링크 : [CS 문답] Builder 패턴이 무엇인가요?