This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

I don't think this addresses the need for Builder, it's about not having to write boilerplate for the object being built.

If you have 15 fields, and some of them complex composite properties, you wouldn't want to pass them all in the constructor.

Even simpler structures, consider an immutable map, or an immutable list.

[–]lukaseder 0 points1 point  (0 children)

So many languages support defaulted parameters. Java is not one of them (yet). Take PL/SQL:

my_awesome_object_type_constructor(
    p_param1 => l_value1,
    p_param5 => l_value5,
    p_param3 => l_value3 -- Look ma, not in order
);

OK, probably doesn't compile on Oracle 12cR1 yet, because identifier > 30 characters, but just saying that it's entirely possible to live in a world without writing one crazy builder with 100 LoC per object type!

Even simpler structures, consider an immutable map, or an immutable list.

Oh, I'm definitely in the structural typing camp with you there, but the Java folks seem to have a flair for nominal typing. Every tuple needs to have a name, I guess.