D
Dinsdale
I was discussing class architecture with one of the senior developers
at my new job and him and I have a similar idea on how to work with
data access and class libraries. That said, our implementations vary
slightly and I wanted to post the question to the .Net community to get
some feedback. So here is the issue:
When designing classes both the senior developer and I agree that data
access should be abstracted out from a business object class by way of
a "factory layer" that communicates between the data access layer and
the business class itself. The factory layer returns an instance of the
object requested based on an ID field used to retrieve the instance
info in the DB. I like to create static methods on the Class being
created that wrap a static factory class and return the object; where
as he believes in creating an instance of the factory that returns the
new object.
My Method (static):
MyWidget mwInstance = MyWidget.GetWidget(555);
//MyClass.GetWidget Wraps static method MyWidgetFactory.GetWidget(int
intWidgetID);
His Method(instance):
MyWidgetFactory mwfFactory = new MyWidgetFactory();
MyWidget mwInstance = mwfFactory.GetWidget(555);
I devised my method while working in a windows environment so I knew
that a limited number of users or processes is accessing the DB. I am
now working in a Web environment, which means "unlimited" users or
processes accessing this code. So, my questions are thus:
1) Is either method perferrable (Static vs. Instance)?
2) Will environment affect performance when creating new instances?
3) If so, which methodology will perform better in a web environment?
Cheers
Dinsdale
at my new job and him and I have a similar idea on how to work with
data access and class libraries. That said, our implementations vary
slightly and I wanted to post the question to the .Net community to get
some feedback. So here is the issue:
When designing classes both the senior developer and I agree that data
access should be abstracted out from a business object class by way of
a "factory layer" that communicates between the data access layer and
the business class itself. The factory layer returns an instance of the
object requested based on an ID field used to retrieve the instance
info in the DB. I like to create static methods on the Class being
created that wrap a static factory class and return the object; where
as he believes in creating an instance of the factory that returns the
new object.
My Method (static):
MyWidget mwInstance = MyWidget.GetWidget(555);
//MyClass.GetWidget Wraps static method MyWidgetFactory.GetWidget(int
intWidgetID);
His Method(instance):
MyWidgetFactory mwfFactory = new MyWidgetFactory();
MyWidget mwInstance = mwfFactory.GetWidget(555);
I devised my method while working in a windows environment so I knew
that a limited number of users or processes is accessing the DB. I am
now working in a Web environment, which means "unlimited" users or
processes accessing this code. So, my questions are thus:
1) Is either method perferrable (Static vs. Instance)?
2) Will environment affect performance when creating new instances?
3) If so, which methodology will perform better in a web environment?
Cheers
Dinsdale