View Single Post
Old January 6th, 2009, 10:00 AM
absolutezero absolutezero is offline
Registered User
Join Date: Aug 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question about Class Design

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:

   public abstract class BaseObject
      public int ID {get; set;}
      public DateTime CreatedDate {get; set;}
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:

  FooClass f = new FooClass();

   FooClass f = FooClass.LoadById(1);
Does anyone have any thoughts on this? Thanks