Skip to content

Commit f66639c

Browse files
authored
Update builder.md (#433)
1 parent 5eb26bd commit f66639c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/patterns/creational/builder.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ Prevents proliferation of constructors.
7373

7474
Can be used for one-liner initialisation as well as more complex construction.
7575

76+
When you add new fields to the target struct, you can update the builder to
77+
leave client code backwards compatible.
78+
7679
## Disadvantages
7780

7881
More complex than creating a struct object directly, or a simple constructor
@@ -81,9 +84,9 @@ function.
8184
## Discussion
8285

8386
This pattern is seen more frequently in Rust (and for simpler objects) than in
84-
many other languages because Rust lacks overloading. Since you can only have a
85-
single method with a given name, having multiple constructors is less nice in
86-
Rust than in C++, Java, or others.
87+
many other languages because Rust lacks overloading and default values for
88+
function parameters. Since you can only have a single method with a given name,
89+
having multiple constructors is less nice in Rust than in C++, Java, or others.
8790

8891
This pattern is often used where the builder object is useful in its own right,
8992
rather than being just a builder. For example, see

0 commit comments

Comments
 (0)