I have a POJO which has tens of fields, and I have to set all the fields' values.
How to avoid forgetting to set some field's value?
// POJO
public class Employee {
private Date birthday;
private String firstName;
private String lastName;
private String birthOfPlace;
// ...
// setters and getters
}
// Main class
public class MainClass {
public static void main(String[] args) {
Employee employee = new Employee();
// Call all the setters of Class Employee
employee.setFirstName("Jack");
employee.setLastName("Reed");
employee.setBirthOfPlace("Iceland");
// Oops, forget to call setBirthday()
}
}