DEV Community

Discussion on: My Top 4 Patterns for Writing Simple Code

Collapse
 
dangoslen profile image
Dan Goslen

Hey Sergiy. Thanks for the reply.

I took a look at your article and you make a lot of great points. However, I don't think it applies in all cases since default values might apply in many scenarios.

I do like the ordering of values that your implementation creates! I think it would be very compelling if an entire codebase had the exact same ordering of required values - so much easier to read.

Thanks again.

Collapse
 
siy profile image
Sergiy Yevtushenko

Yes, that's exactly the point: assembling POJO's usually is the case when Builder should not be used because POJO's in vast majority of cases don't have default values. Nevertheless, Fluent Builder can be modified to handle case when some values have defaults. And only in case when all values have defaults traditional form of Builder can be used.