C
csharper
I have been wondering about this for a while. Suppose I have a class
Employee which has defined the following properties:
EmployeeId
FirstName
MiddleName
LastName
.... ...
Suppose now in another class, I need to use the employeeId in a method
GetContactInfo.
Now, should I pass an Employee object to GetContactInfo like below?
// Version 1.
public IEnumerable<ContactInfo> GetContactInfo(Employee employee)
{
// The implementation goes here.
}
Or should I simply pass the EmployeeId int like below?
// Version 2.
public IEnumerable<ContactInfo> GetContactInfo(int employeeId)
{
// The implementation goes here.
}
Both will work, but
Q1: From an OOP perspective, which is more OOP-like?
Q2: Which version has better performance? Version 1? Version 2? No
difference?
Thank you.
Employee which has defined the following properties:
EmployeeId
FirstName
MiddleName
LastName
.... ...
Suppose now in another class, I need to use the employeeId in a method
GetContactInfo.
Now, should I pass an Employee object to GetContactInfo like below?
// Version 1.
public IEnumerable<ContactInfo> GetContactInfo(Employee employee)
{
// The implementation goes here.
}
Or should I simply pass the EmployeeId int like below?
// Version 2.
public IEnumerable<ContactInfo> GetContactInfo(int employeeId)
{
// The implementation goes here.
}
Both will work, but
Q1: From an OOP perspective, which is more OOP-like?
Q2: Which version has better performance? Version 1? Version 2? No
difference?
Thank you.