Skip to main content
Improvements to returning companies
Source Link
AJNeufeld
  • 35.3k
  • 5
  • 41
  • 103

Your Employee is frozen in time; they can never get any older!

Age should be calculated from date-of-birth and “today”, not stored in an immutable field.


The getCompanies() method could be written simply as:

return new ArrayList<>(this.companies); 

Or perhaps:

return Collections.unmodifiableList(this.companies); 

Your Employee is frozen in time; they can never get any older!

Age should be calculated from date-of-birth and “today”, not stored in an immutable field.

Your Employee is frozen in time; they can never get any older!

Age should be calculated from date-of-birth and “today”, not stored in an immutable field.


The getCompanies() method could be written simply as:

return new ArrayList<>(this.companies); 

Or perhaps:

return Collections.unmodifiableList(this.companies); 
Source Link
AJNeufeld
  • 35.3k
  • 5
  • 41
  • 103

Your Employee is frozen in time; they can never get any older!

Age should be calculated from date-of-birth and “today”, not stored in an immutable field.