473,503 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Should Data Classes be Shared/Static Assemblies?

Here's a design question I'm curious to know if anyone here has wrestled
with before...

I'm writing my data access methods in classes in the App_Code directory. I
know that I can easily instantiate each class on a page and run it's
functions to get my data from the database. However, I'm wondering if I
could pick up performance if I made all the functions shared/static. Then
I'm wondering if it would be worth it because of the design issues - namely
that I would have to pass in a parameter that would indicate which database
the function would have to access (each client group has it's own database).
If they're not shared/static I can pass in the parameter on the constructor.

I want to be able to still take advantage of connection pooling. Any ideas?
Dec 19 '06 #1
2 1616
This sentence in and of itself is bad design:

"data access methods in classes in the App_Code directory"

Your data layer ought to be an a separate assembly.
If you ever needed to put an database access stuff
in a windows service or perhaps a windows application,
you couldn't just copy the dll.

The methods being static won't affect connection pooling.

Personally, I like to have my data access methods static to
save lines of code instantiating objects. I also keep
static arrays of custom attributes and PropertyInfo stuff
because of the sql server object mapper mentioned below.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/..._generator.asp

"Random" <ci*******@hotmail.comwrote in message
news:uO****************@TK2MSFTNGP04.phx.gbl...
Here's a design question I'm curious to know if anyone here has wrestled
with before...

I'm writing my data access methods in classes in the App_Code directory.
I know that I can easily instantiate each class on a page and run it's
functions to get my data from the database. However, I'm wondering if I
could pick up performance if I made all the functions shared/static. Then
I'm wondering if it would be worth it because of the design issues -
namely that I would have to pass in a parameter that would indicate which
database the function would have to access (each client group has it's own
database). If they're not shared/static I can pass in the parameter on the
constructor.

I want to be able to still take advantage of connection pooling. Any
ideas?

Dec 20 '06 #2
I have to respectfully disagree with you, Robbe, that this is bad design.
Our programming group is mired right now in a very poorly performing
application because the application was abstracted so much that data access
and tasks were a nightmare for any new functionality or database schema
changes to the application; which happens to be often.

We expect to correct these problems by elimintating "awareness" of the
database schema in the application front end, and handling all the business
logic (outside of some validation) through custom classes and explicit
stored procedures. If we expect to need to share an assembly with a windows
service or windows application, we'll write one for that purpose and put it
in the GAC.

But, yes, I also had hoped to be able to write my data access methods as
shared/static to avoid the instantiation of objects when the page processes;
and if each business client didn't have their own database, that would be a
piece of cake. Now, if I can't make my functions shared/static because of
this, I'm wondering if/how I can make use of the HttpContext.Items to keep
from needing to reference more than one per page process, or maybe have the
objects part of a thread pool I can pull them from.

"Robbe Morris [C# MVP]" <jo*****@joe.comwrote in message
news:56**********************************@microsof t.com...
This sentence in and of itself is bad design:

"data access methods in classes in the App_Code directory"

Your data layer ought to be an a separate assembly.
If you ever needed to put an database access stuff
in a windows service or perhaps a windows application,
you couldn't just copy the dll.

The methods being static won't affect connection pooling.

Personally, I like to have my data access methods static to
save lines of code instantiating objects. I also keep
static arrays of custom attributes and PropertyInfo stuff
because of the sql server object mapper mentioned below.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/..._generator.asp

"Random" <ci*******@hotmail.comwrote in message
news:uO****************@TK2MSFTNGP04.phx.gbl...
>Here's a design question I'm curious to know if anyone here has wrestled
with before...

I'm writing my data access methods in classes in the App_Code directory.
I know that I can easily instantiate each class on a page and run it's
functions to get my data from the database. However, I'm wondering if I
could pick up performance if I made all the functions shared/static.
Then I'm wondering if it would be worth it because of the design issues -
namely that I would have to pass in a parameter that would indicate which
database the function would have to access (each client group has it's
own database). If they're not shared/static I can pass in the parameter
on the constructor.

I want to be able to still take advantage of connection pooling. Any
ideas?


Dec 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
741
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
1
2499
by: Mythran | last post by:
I have 2 assemblies (for example). Assembly A references assembly B. If I have a value in assembly A that I want to be used in assembly B, how can I store it so that assembly B can access it...
9
4163
by: Invalidlastname | last post by:
Hi, We developed some assemblies which use EnterpriseServices queued components. In order to use EnterpriseServices, these assemblies need to be installed into GAC. I used the pre-build and...
3
1857
by: Phillip Ian | last post by:
Just a quick architecture question. I'm just looking for discussion, not a flame war, please. In the past, I've tended to use a public module for my data layer functions. Something like: ...
1
1266
by: DaBrain | last post by:
Thanks for any replies in advance. I am C# Developer messing with VB.NET because I must move MANY Functions on a web site that are written in inline HTML <SCRIPT and I want to put them all in...
0
1140
by: =?Utf-8?B?VG9tIE1jTGVvZA==?= | last post by:
We are migrating an application from VS.NET 2003 to VS 2005. The client and server have many types passed via web services that are shared in common assemblies. In VS.NET 2003, we used a custom...
16
1832
by: chameleon | last post by:
I have 2 classes with exactly the same members (all static except dtor/ctor). Classes have different implementantion in only one static member function and first class has one more member...
6
2163
by: Immortal Nephi | last post by:
First class is the base class. It has two data: m_Base1 and m_Base2. Second class and third class are derived classes and they are derived from first class. m_Base1 and m_Base2 are inherited into...
5
2631
by: Andy B | last post by:
I have a class that I want to make static but it uses some objects that are instance objects. I keep getting a compiler error saying something about using instance objects in a static class or...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7342
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.