So I've been writing a new piece of software for my company and I am diving into the use of generics for the first time (Just got VS2005 not too long ago).
So I've been building my classes based on code I've found throughout the net and found some very good articles to base my work/learning off of.
However, everyone has simplified their code to get their point across and I have been left with working my design into their code structure. I am wondering if I did this right.. or atleast "smart".
I have a few derived classes from a main DataObject class which is ultimately the object part of my data-object seperation.
The above is a rough copy of what I am doing, but is enough to ask the question:
I have no Factory class but I am using static methods like a factory design. I didn't realize this until I got about half-way through and decided I would continue to see what I came up with. Now that I am finished, I can see no problems but I really want a more expert opinion on this design.
Should I seperate my factory methods and forget about static methods? Another thing is the use of a static datatable field... Is it going to be overwritten by another call to a Create() method and thus all my previous objects dataRow will be lost?
Is this somehow ingeniously unique? or am I just barking up the wrong tree completely?
So I've been building my classes based on code I've found throughout the net and found some very good articles to base my work/learning off of.
However, everyone has simplified their code to get their point across and I have been left with working my design into their code structure. I am wondering if I did this right.. or atleast "smart".
I have a few derived classes from a main DataObject class which is ultimately the object part of my data-object seperation.
Code:
class MyObject : MasterDataObject, ISomething, INotifyblahblah
{
//constructor
private MyObject()
{
}
protected StrongDataRow dataRow;
//Primary key of data in database
private int objectID;
public int ObjectID
{
get {} private set {}
}
private int someFieldData;
public int SomeFieldData
{
get {} set {}
}
//All methods below are from an Interface or derived class
private override void PopulateData()
{
//use this.dataRow to fill appropriate fields
}
public override bool Update()
{
//assign changed fields to this.dataRow and then..
MyObject.dataAdapter.Update(this.dataRow);
}
public override void Revert() {...}
//Static Methods (from an Interface)
protected static StrongDataAdapter dataAdapter;
protected static StrongDataTable dataTable;
public static GetAllInstances()
{
//use static adapter and table to get data
//and tag datarow to objects for later updating
//if needed i.e.:
MyObject.table = dataAdapter.GetData(); // returns strong DataTable
}
public static GetnstancesFromID(int ID)
{
//use static adapter and table to get data
//and tag datarow to single object for later updating
//if needed
}
public static CreateNewInstance()
{
//use static adapter and table to create new datarow
//and tag datarow to objects for later updating
//if needed
}
}
The above is a rough copy of what I am doing, but is enough to ask the question:
I have no Factory class but I am using static methods like a factory design. I didn't realize this until I got about half-way through and decided I would continue to see what I came up with. Now that I am finished, I can see no problems but I really want a more expert opinion on this design.
Should I seperate my factory methods and forget about static methods? Another thing is the use of a static datatable field... Is it going to be overwritten by another call to a Create() method and thus all my previous objects dataRow will be lost?
Is this somehow ingeniously unique? or am I just barking up the wrong tree completely?