Maybe Constructors are Nicer?

  • If you use setters to "set up" an object after creation, constructors may be better
  • The object can be built "all at once" using a constructor
// Using setters. Can be modified later
Employee ryan = new Employee();
ryan.setName("Ryan Kadri");

// Using Constructor. Can be locked down and not modifiable
Employee ryan = new Employee("Ryan Kadri", 28, "Developer");

8 / 22