Arne Vajhøj said:
[...]
I have a third suggestion that you could use instead of options 1 and 2:
Place the GetContactInfo method INSIDE the Employee class. In that way
you would not have to pass any argument.
[...]
That suggestion *combined* with actually storing the contact
info in the employee object make sense.
Just adding the method but not have the data does not look good
You may, or may not, store the contact data inside the Employee objet.
The point I wanted to make when I made the suggestion was that such
storing of the data would be an internal implementation detail, and it
should be transparent to the callers of Employee.GetContactInfo(). The
implementation details are kept hidden inside the class; the callers
should not have to care about how the class operates internally. In
fact, you could write a first version that fetched the data from the
database every time the method was called, and if the performance
happened to be unacceptable, you could then rewrite it so that the
contact info was cached in memory. This change in implementation would
be transparent to the callers; no part of the code that uses the
Employee class would have to be rewritten due to this internal change in
the class.