Guys I have a “best practice question” For example I have this classes:
class Person
{
public int age {get; set;}
}
class Computer
{
public void checkAge(Person p) // Which one is recommended THIS
{
// Do smthg with the AGE
}
public void checkAge(int p) // OR THIS
{
//Do smthg with the age.
}
}
What is recommended to pass? Just what I need (int-value type) or the whole object (reference type)
Im asking this because Im using LINQ on an app that I am making and I have created many entities where I should pass the IDs (foreing keys), but Im passing objects.
What is the best approach?
The function
checkAgeshould only take in the minimum amount of information needed to perform it’s job. Adding anything else just creates an artificial dependency. If only anintis needed then that is the solution I should take.