Hello,
I am working on a class library, a sort of framework I guess, and am looking for some advice. Right now I am working with just my objects that represent database tables. Every single object in my class library has a series of fields that are part of each database table (ID, Created Date, etc) so, for this, I have created a base class that all of my objects inherit from similar to:
Code:
public abstract class BaseObject
{
public int ID {get; set;}
public DateTime CreatedDate {get; set;}
//etc
}
This isn't a problem. The question that I have is related to interfaces and, i suppose a "best practice". Initially I was just going to add all of the other members for my object directly into the class, however, I toyed around with the thought of using an interface for the implementation of the members to tie everything together. Furthermore I am putting the CRUD methods directly on the object and was thinking about putting these inside of the interface as well but I am torn since a method defined in an interface can not be implemented as static in the inheriting class.
I suppose it is a matter of opinion whether one prefers to do:
Code:
FooClass f = new FooClass();
f.LoadById(1);
Console.WriteLine(f.Name);
or
Code:
FooClass f = FooClass.LoadById(1);
Console.WriteLine(f.Name);
Does anyone have any thoughts on this? Thanks