Assuming you are effectively applying defaults, the usually best approach is to have one "full" constructor and force others to call it. For instance:
public Foo(String name)
{
this(name, null);
}
public Foo(String name, String description)
{
this.name = name;
this.description = description;
}
, "" - . , , - . , .
- " ", , - , . , . , , :
FooParameters parameters = new FooParameters()
.setName("some name")
.setDescription("some description");
// Either a constructor call at the end, or give FooParameters
// a build() or create() method
Foo foo = new Foo(parameters);
, , , - , , . Java ProcessBuilder, , , , , , : (
- , (build, create, start, ), . .
Java ,
Foo foo = new Foo.Builder().setName(...).setDescription(...).build();
, Foo.