Java | Builder Design Pattern
Java POJO classes can be created using different design patterns. Below is example how Builder pattern works.
Normally, Simple java POJO class setter-call has void return type. Builder pattern replace void return type and returns current object of class(ie. return this). Builder pattern can be used to replace parameterised constructor. Also when we create object the code is more readable.
Example :
Normally, Simple java POJO class setter-call has void return type. Builder pattern replace void return type and returns current object of class(ie. return this). Builder pattern can be used to replace parameterised constructor. Also when we create object the code is more readable.
Example :
Comments
Post a Comment