Class Design - Returning a List<Object> From <Object>
Posted
by Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2010-04-16T00:02:51Z
Indexed on
2010/04/16
0:13 UTC
Read the original article
Hit count: 567
Given a simple class:
public class Person
{
public string FirstName;
public string LastName;
public string GetFullName()
{
return FirstName + LastName;
}
}
The user of this class will populate a List<Person>
object by reading an Xml file or some other data source. Should the logic for populating the List be in the Person class or should it just remain in the calling class? In other words, should there be a public List<Persons> GetPersons()
method in the Person class or in the calling class? Or should the data accessor be in another class altogether?
I know this is a rather simplistic question but I'm just curious how others typically do it.
© Stack Overflow or respective owner