Below are two examples of loading a person from the database. I find the static method cleaner to write, but it creates difficulty when using abstract/virtual methods and interfaces.
So which is better practice?
Static:
class Person
{
public static Person Load(int id)
{
// Returns person from database
}
}
var id = 1;
var person = Person.Load(id);
Non-static:
class Person
{
public Person Load(int id)
{
// Returns person from database
}
}
var id = 1;
var person = new Person().Load(id);