mardi 11 septembre 2018

Using builder inside another builder in Java

Is it a good practice to use builder inside another builder in Java or it would be better to add methods to builder of 'higher' level to create object behind the scenes?

new Car.CarBuilder().engine(new Engine.EngineBuilder().name("Diesel").weight(5).build()).build();

Aucun commentaire:

Enregistrer un commentaire