Re: Can this Class be cleaned up at all?



John T wrote:

private float initialSalary;

float is almost always the wrong type. It only has the equivalent of 24
significant bits, less than 8 significant digits. That means the cents
figure of a high annual salary might be in danger.

Either BigDecimal, or an integer count of cents (or other minimal
currency unit), works well. If you really need floating point operations
on your salaries, use double.

public Employee(int employeeNumber, String employeeName, Calendar date, float initialSalary) {
this.employeeNumber = employeeNumber;
this.employeeName = employeeName;
this.initialSalary = initialSalary;
this.hireDate = date.getTime();
}

You could use:
this(employeeNumber, employeeName, date, initialSalary, 0);

instead of the method body. That makes it easier to see that it is doing
the same thing as the six argument constructor, but with the salary left
zero.

....
Is there anything that can be changed to make it look less clunky? I was thinking about making it an interface and having it implemented but when I thought about the IS-A HAS-A guideline I thought it would make more sense to have the Employee class and an interface called EmployeeDoes to encapsulate the methods.

Would doing that gain any flexibility that you think you would find
useful in your program?

Patricia
.