473,766 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data Access Logic Components

I would just like to get a feeling for what others are doing here. Having
read through the 'Data Tiers' paper under MS's Paterns and Practices I am
designing and developing a small(ish) 3 layered web app. Now I've come to
design the DALC classes I cannot see any reason why I would make these
methods instance methods. It seems to me that they only need be static
methods. The DALC is purely a class definition with a bunch of methods that
call on stored procs and return DataSets. I can't see any reason for
constructor code here or any inheritance, therefore all these methods could
be static right?
--
MG
May 23 '06 #1
3 1622

One reason I use the constructor, is to be able to switch up which db I
might use.

Or instance.
class UserInfo
{
private string m_connectString = string.Empty;

//constructor1
public UserInfo()
{
//no connection string was given , so read it from the config
if (null!=Configur ation["MyAppConnectio nString"]) // The syntax if
off here, I"m going from memory, but the object which reads config file
AppSettings
{
this.m_connectS tring=Configura tion["MyAppConnectio nString"];
}
else
{
throw new ArgumentExcepti on("MyAppConnec tionString not defined in config
file");
}
}

//constructor2
public UserInfo(string connectString)
{

this.m_connectS tring=connectSt ring;

}

}
I actually don't do that anymore, as I use the EnterpriseLibra ry
dataconfigurati on.config, but I use the same concept.
Anyway, I am just posting a reason why you might consider a instaniated
object with multi constructors.

...

My code runs against multiple databases (where a database is a client, but
the clients all have copies of the same db model) ... since I write good
data layer objects, I like to be able to send in alternate connectionStrin gs
as needed. The overloaded constructor does this, but has the "easy
constructor", if I don't send it in.
"Mark Gilkes" <ma*********@NO SPAMgmail.com> wrote in message
news:14******** *************** ***********@mic rosoft.com...
I would just like to get a feeling for what others are doing here. Having
read through the 'Data Tiers' paper under MS's Paterns and Practices I am
designing and developing a small(ish) 3 layered web app. Now I've come to
design the DALC classes I cannot see any reason why I would make these
methods instance methods. It seems to me that they only need be static
methods. The DALC is purely a class definition with a bunch of methods that call on stored procs and return DataSets. I can't see any reason for
constructor code here or any inheritance, therefore all these methods could be static right?
--
MG

May 23 '06 #2
Thus wrote Mark,
I would just like to get a feeling for what others are doing here.
Having read through the 'Data Tiers' paper under MS's Paterns and
Practices I am designing and developing a small(ish) 3 layered web
app. Now I've come to design the DALC classes I cannot see any reason
why I would make these methods instance methods. It seems to me that
they only need be static methods. The DALC is purely a class
definition with a bunch of methods that call on stored procs and
return DataSets. I can't see any reason for constructor code here or
any inheritance, therefore all these methods could be static right?


IMHO, for anything other than the most trivial helper class (stuff like System.Web.Http Utility),
stay clear of static classes. In OO development, there's one rather fool
proof way to run into trouble: *Not* using objects.

When your DAL consist only of static classes, there's no clean way to decouple
your business layer from them for test purposes or to replace them with a
different implementation (say SQL Server 2005 for Oracle). The latter may
never be relevant for your applicaton, but the former always is. A unit test
for a Method B() in a business component A that uses a data access component
shouldn't be really accessing the database, but use a mock implemetation
of the data access component that returns some well defined result. Otherwise
you're not testing your business component in isolation.

I also think that your assumption about never finding a use for inheritance
is wrong. Unless your DAL is utterly trivial, you'll quickly discover some
common functionality in your DAL. This will all end up in private or internal
static methods or yet another helper class, but not in any meaningful object
hierarchy.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
May 25 '06 #3
Mmm, thanks for your comments folks!
May 26 '06 #4

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

Similar topics

9
3313
by: Tony Lee | last post by:
Some time a ago, on this newsgroup the following comments were made in recommending good references for Access (2003) >I used to recommend Dr. Rick Dobson's, "Programming Access <version>" for >people moving from power user to developer, but now I suggest you browse >it, >too. It strongly emphasizes ADO, which knowledgeable Microsoft insiders no >longer recommend, and the Access ADP client to SQL Server. He writes well, >and is a good...
3
4759
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing around chunks of data in DataTables/DataSets, simply because that was the format that they were in when the data was taken from the database. Now, I know this maybe a pretty silly question with a standard "it depends" answer, but I'm going to...
41
4731
by: laimis | last post by:
Hey guys, I just recently got introduced to data mappers (DTO mapper). So now I have a SqlHelper being used by DTOMapper and then business layer is using DTOMapper when it needs to persist object to database or load them back. Everything is working nicely so far. My question is, is it OK practice to use DTOMapper rfom the presentation layer? For instance, if I want to present in HTML format the list of entries in my database, should I...
3
1879
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: public module db Friend ConnectionString As String = "" Public Sub InitializeDB(ByVal AConnectionString As String)
10
1668
by: Doug Bell | last post by:
Hi, I have an application that has a "Data Access Class" and "User Interface Class". It is for receiving Purchase Order data from one system and pushing processed transactions to another system. The system generally works quite well. Currently the User interface calls for a refresh of data every 15 minutes (selectable) and the Data Access Class connects to the DB and retrieves the
30
3404
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on the dataset or connection? TIA
4
3019
by: pratham | last post by:
Hi! I'm making a database application and i heard from a friend that it is more proffecional and easy to do this with bussines objects. Can anyone tell me where i can find more info on bussines objects and how to implement them with c#? I would appreciate any help. How can i decide that what things go into business layer and what
2
2642
by: grawsha2000 | last post by:
Greetings, I am developing this N-tier business app. The problem I'm facing is when I try to pass business objects (employees, dept..etc) from business tier to data tier,i.e., the add method in the data tier expects business object from the business tier, I get an error saying: Can not covert businesslayer.emp to businesslayer.emp
6
2421
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The connection string works fine and the tables are added to the project without a problem. When I create the tables they appear to bind and I am able to preview the data in the database in design mode; however, at runtime no data is displayed and the...
0
9571
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10009
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9838
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8835
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7381
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.