My Question is when i am having list of objects, should i pass the entire list to a methods in another layer or should i have another model and make the new list of it?
namespace Model
{
Public Class class2
{
blah blah properties
}
Public Class Person
{
public string firstname { get; set; }
public string lastname {get; set;}
public int age {get; set;}
public Datetime regDate {get; set;}
public class2 SomeClass{get; set;}
}
}
Namespace Service
{
Namespace Model
{
public class LogPerson
{
public string firstName {get; set;}
public string lastName {get; set;}
public int age {get; set;}
}
}
public static class Log
{
//Method1
public void Log(List<Person> persons)
{
LogProvider.Log(Persons.Select(p=> new LogPerson{ p.firstName, p.lastname, p.age}).ToList());
}
//Method2
public void Log(List<LogPerson> persons)
{
LogProvider.Log(persons);
}
}
As i showed above, is it good practice to pass the complete list of persons object (Log provider needs only firstname,lastname and age) or using method2 which needs the LogPerson object from the beginning.
I do not need opinions, what i need is,according to separation of concerns, which one is right way ?
Aucun commentaire:
Enregistrer un commentaire