wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

By Date: October 2026

Builder pattern with flexible defaults

Hero image for Builder pattern with flexible defaults

objects in real life are complex with many optionalities (my spell checker claims that isn't a word), that leave their imprint on their digital twins. To avoid exposing endless list of parameters you can use the builder pattern described by the GoF. It is the digital version of

This is what I know, let's work with that

You might want to go with the flow, and just pick a size and for the rest pick what everyone else is picking. The builder pattern does both gracefully.

Ring r1 = Ring.builder().size(9)build();

Ring r2 = Ring.builder()
              .material(Material.PLATINUM)
              .size(9)
              .diamonds(3)
              .carats(0.75)
              .engraving("forever")
              .build();

or if Rust rocks your boat

let r3 = RingBuilder::builder()
                     .material(Material::Platinum)
                     .size(9)
                     .diamonds(3)
                     .carats(0.75)
                     .engraving("forever")
                     .build();

So I was wondering what it would take using defaults from a configuration file instead hard coding them in the builder.


Read more

Posted by on 14 October 2026 categories: JavaRust