473,761 Members | 10,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Advice on Data Layer

I want to create an n-tier app and I would like an advice of you that
know more than me about this.

I want my app to support multiple databases in the way that when a
client wants to use Oracle and not SQL server, I can easily port the
data layer without touching the rest of the code.

So, I have 2 ideas.

1: Take the way MS Pet Shop did (I read a LOT in many sites how this
architecture is flawed) in creating an IDAL where i declare DAL
interfaces to all my objects and implement them in the real DAL (SqlDAL,
OracleDAL, etc).

2: Create abstract classes that implement common code to all the DALs
(like some selects are really equal in any database) and override them
in the real implementation providing the code that is different.

Both of them include am Data Access Interface to provide common way to
access all the data from a single point, and a Factory to choose which
DAL I should use.

I would like to know from you what is best in your opinion, even other
idea that i didn't write. I don't know if my references are the best ones.

Other thing that I am in doubt is that way MS pet shop uses to
instantiate classes. Is there any performance issues using
Assembly.Create Instance(string )? I'm afraid that when using lots of
requests per second, this could affect the application.

Thanks in advance.
Nov 19 '05 #1
5 1417
Hi Natan:

I haven't looked at MS Pet Shop so I really can't comment there, but
since it was written primarly to win benchmark tests I'd look at it
with a grain of salt, as you have.

Factory and Provider patterns are a solid approach to achieving
support for multiple backends. These are the fancy terms for your
option #2. There are a few working examples to take a look at:

DAAB v3:
http://www.gotdotnet.com/workspaces/...c-aaeb21d1f431

DNN uses a provider pattern:
http://dotnetnuke.com/

And some theory:

Provider Design Pattern, Part 1 & 2
http://msdn.microsoft.com/library/de...sp04212004.asp
http://msdn.microsoft.com/library/de...sp04212004.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 23 Dec 2004 13:24:11 -0200, Natan <nv********@man dic.com.br>
wrote:
I want to create an n-tier app and I would like an advice of you that
know more than me about this.

I want my app to support multiple databases in the way that when a
client wants to use Oracle and not SQL server, I can easily port the
data layer without touching the rest of the code.

So, I have 2 ideas.

1: Take the way MS Pet Shop did (I read a LOT in many sites how this
architecture is flawed) in creating an IDAL where i declare DAL
interfaces to all my objects and implement them in the real DAL (SqlDAL,
OracleDAL, etc).

2: Create abstract classes that implement common code to all the DALs
(like some selects are really equal in any database) and override them
in the real implementation providing the code that is different.

Both of them include am Data Access Interface to provide common way to
access all the data from a single point, and a Factory to choose which
DAL I should use.

I would like to know from you what is best in your opinion, even other
idea that i didn't write. I don't know if my references are the best ones.

Other thing that I am in doubt is that way MS pet shop uses to
instantiate classes. Is there any performance issues using
Assembly.Creat eInstance(strin g)? I'm afraid that when using lots of
requests per second, this could affect the application.

Thanks in advance.


Nov 19 '05 #2
Natan wrote:
I want to create an n-tier app and I would like an advice of you that
know more than me about this.

I want my app to support multiple databases in the way that when a
client wants to use Oracle and not SQL server, I can easily port the
data layer without touching the rest of the code.

So, I have 2 ideas.

1: Take the way MS Pet Shop did (I read a LOT in many sites how this
architecture is flawed) in creating an IDAL where i declare DAL
interfaces to all my objects and implement them in the real DAL (SqlDAL,
OracleDAL, etc).

2: Create abstract classes that implement common code to all the DALs
(like some selects are really equal in any database) and override them
in the real implementation providing the code that is different.

Both of them include am Data Access Interface to provide common way to
access all the data from a single point, and a Factory to choose which
DAL I should use.

I would like to know from you what is best in your opinion, even other
idea that i didn't write. I don't know if my references are the best ones.

Other thing that I am in doubt is that way MS pet shop uses to
instantiate classes. Is there any performance issues using
Assembly.Create Instance(string )? I'm afraid that when using lots of
requests per second, this could affect the application.

Thanks in advance.


I created a data access framework for my current ASP.Net project. It uses XML
files to associate tables with a data object. I also made interfaces for the
web front end. The impl objects tie the two together and each configures its
own database accessor (per the XML files). It when builds the general SQL
code and caches it. The database accessor object only uses the IData...
interfaces. The real trick is getting parameter objects that must be tied to
the actual database engine being used. I created a database gateway interface
that the accessor uses and the impl passes on initialization. From the
gateway object, the accessor gets the connection string, maps DbTypes to the
correct types (in my case SqlTypes) and creates concrete IParameter objects.
So far, the only real drawback is in trying to preserve nulls in the data rows
as many of the .Net object types (IntXX, Datetime, Decimal, etc) do not
support nulls.

Nov 19 '05 #3
No One wrote:
I created a data access framework for my current ASP.Net project. It uses XML
files to associate tables with a data object. I also made interfaces for the
web front end. The impl objects tie the two together and each configures its
own database accessor (per the XML files). It when builds the general SQL
code and caches it. The database accessor object only uses the IData...
interfaces. The real trick is getting parameter objects that must be tied to
the actual database engine being used. I created a database gateway interface
that the accessor uses and the impl passes on initialization. From the
gateway object, the accessor gets the connection string, maps DbTypes to the
correct types (in my case SqlTypes) and creates concrete IParameter objects.
So far, the only real drawback is in trying to preserve nulls in the data rows
as many of the .Net object types (IntXX, Datetime, Decimal, etc) do not
support nulls.


Thanks for your answer. About the nulls, while we don't have .net 2.0, I
found a nice project in sourceforge that may help solve the problems for
a while:

http://nullabletypes.sourceforge.net/
Nov 19 '05 #4
Scott Allen wrote:
Factory and Provider patterns are a solid approach to achieving
support for multiple backends. These are the fancy terms for your
option #2. There are a few working examples to take a look at:


Thanks. I'll take a look.
Nov 19 '05 #5
I built a DAL for SQL Server and Oracle.
When I was done I looked at the MS DAAB and found them to be very similar.
So you should look at that first.

I just "translated " things like SqlConnection and OracleConnectio n to
IConnection.
My DAL reads a config file which defines which DB to use - SQL Server or
Oracle.
Then each method branches accordingly and returns the correct concrete
instance:
e.g. SqlConnection when running SQL Server.

--
Joe Fallon


"Natan" <nv********@man dic.com.br> wrote in message
news:ek******** ******@TK2MSFTN GP11.phx.gbl...
I want to create an n-tier app and I would like an advice of you that know
more than me about this.

I want my app to support multiple databases in the way that when a client
wants to use Oracle and not SQL server, I can easily port the data layer
without touching the rest of the code.

So, I have 2 ideas.

1: Take the way MS Pet Shop did (I read a LOT in many sites how this
architecture is flawed) in creating an IDAL where i declare DAL interfaces
to all my objects and implement them in the real DAL (SqlDAL, OracleDAL,
etc).

2: Create abstract classes that implement common code to all the DALs
(like some selects are really equal in any database) and override them in
the real implementation providing the code that is different.

Both of them include am Data Access Interface to provide common way to
access all the data from a single point, and a Factory to choose which DAL
I should use.

I would like to know from you what is best in your opinion, even other
idea that i didn't write. I don't know if my references are the best ones.

Other thing that I am in doubt is that way MS pet shop uses to instantiate
classes. Is there any performance issues using
Assembly.Create Instance(string )? I'm afraid that when using lots of
requests per second, this could affect the application.

Thanks in advance.

Nov 19 '05 #6

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

Similar topics

8
1571
by: M O J O | last post by:
Hi, I'm creating an CRM solution for my company. I want to split up the solution into several classlibraries, so I dont need to build the entire solution every time I run my project. First I thought about splitting my application up into these libraries: Solution (solution)
1
260
by: Natan | last post by:
I want to create an n-tier app and I would like an advice of you that know more than me about this. I want my app to support multiple databases in the way that when a client wants to use Oracle and not SQL server, I can easily port the data layer without touching the rest of the code. So, I have 2 ideas. 1: Take the way MS Pet Shop did (I read a LOT in many sites how this
4
1125
by: mallen | last post by:
Hi All, I have a web application with the usual 3 layers; presentation, business, and DB. We are just about to start work on a new project with a totally separate presentation layer, but will use SOME of the existing business functionailty and the same DB. Functionailty to be re-used will be a User object for example.
1
2586
by: Johann Blake | last post by:
I am looking for a good solution on how to implement data access in an application so that there is a clean separation between the data access layer, the business layer and the GUI layer. I am looking for a robust solution for a major application. Almost every developer seems to come up with a completely different solution. While many of them are not bad, I really want a very good one. My database is SQL Server 2000 and I am using Visual...
9
2662
by: Laban | last post by:
Hi, I find myself using static methods more than I probably should, so I am looking for some advice on a better approach. For example, I am writing an app that involves quite a bit of database operations on purchase orders and inventory. I have created a PurchaseOrder class and Inventory class to encapsulate operations like creating POs, finding items, etc. These two classes are used extensively from different parts of the app.
6
1407
by: V. Jenks | last post by:
I apologize if this is the wrong forum for this, I could not locate one that was exactly appropriate for this topic. Over the last couple of years I've been doing a lot of reading on design patterns and different types of architectures for building high-performance, scalalble n-tier apps. I've used business objects for a while, since moving to C# and asp.net from classic asp but I'm wondering how I can
3
1447
by: Shapper | last post by:
Hello, Until now I have been using Dreamweaver to create ASP.Net/VB web sites. I gave up of using it. Too many limitations. What is the best software to create ASP.NET/VB web sites? Maybe Web Matrix from ASP.NET. Or Visual Studio?
13
3113
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those sorts of clients. Mine are all small businesses whose sites will never reach those sorts of scales. I deal with businesses whose sites get maybe a few hundred visitors per day (some not even that much) and get no more than ten orders per day....
1
1112
by: MuZZy | last post by:
Hi, I'm going to develop a pretty simple document management application and i want to use WCF to connect back-end to smart client front-end. That application will allow to create a hierarchcal structure where any node can be linked with a document file, which are all stored in a SQL Server database. I'm trying to convince my boss towards smartclient instead of ASP.NET
13
1334
by: terry.holland | last post by:
I have a three tiered CRM application (ASP.Net UI, VB.Net Business Layer & VB.Net Data Access Layer) that consists of number of classes. The application will be deployed to a number of clients. Some of our clients have no existing CRM system and are happy that our application stores Client information. Other clients have already got a CRM system and want our application for the additional functionality that it offers. These clients would...
0
9521
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
10107
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
9945
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
9765
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
8768
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
7324
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
6599
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();...
0
5361
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.