473,378 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

DAL design, assemblies and OO ?(s)

Hi all,

I'm designing my DAL layer(s) for our suite of applications and I'm
designing myself in circles, it's gotten to the point where each idea just
mixes me up more :)

We have 3 loosely related applications and I would like to use an assembly
for the DAL in each of them. I have thought of using a single assembly for
all of them with several different classes for providers/application
specific code, thought of a separate assembly for each application, etc.

I have several questions that I'm hoping will lead to some clarity if I can
get them answered and hopefully you can help with some of the answers.

1) Is there a way to share .cs files across several projects? I'm used to
this with C++, but in c# it seems that this results in a copy of the files
into each project. Is there a way to reference a file from another project?
or just a file by itself?

2) Typically, do companies use one giant DAL assembly for all applications
needing a DAL?

3) From what I understand of things, if I wanted to have 3 DAL assemblies
all inheriting a common "base DAL" class, I would have a total of 4
assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies
for each application?

4) Check out my little inheritance thing below, question will follow:
class DALBase
abstract class DAL_AppCommon : DALBase
class DAL_AppCommonMySql : DAL_AppCommon
class DAL_AppCommonSqlServer : DAL_AppCommon

abstract class DAL_AppInventory : DALBase, DAL_AppCommon
class DAL_AppInventoryMySql : DAL_AppInventory
class DAL_AppInventorySqlServer : DAL_AppInventory

What I'm trying to achieve is to have a concrete instance of say...
DAL_AppInventory and have it inherit the appropriate DAL_AppCommon derived
class. In other words, if I Instantiate DAL_AppInventoryMySql, I would like
it to also have the DAL_AppCommonMySql methods/properties.

I know that I can create a factory for each DAL_App* class and then have a
instance member of DAL_AppCommonMySql in my DAL_AppInventoryMySql, but I
would rather do this with inheritance if possible. I hope that makes sense.
General pointers/tips/clues VERY welcome.

Thank you for reading,
Steve
Feb 9 '06 #1
7 2904
Hi Steve,
Here are the answers:
1. Unlike c++, you cannot reference a c# file. Reference is done at
the assembly level.
2. It depends. It's better to have it in single assembly by properly
structuring. You can abstract all common data access code to one sigle
file with static/shared method and one file each for you business
objects. By this way, you will get clean segregation.
3. What I believe from your writing is - you are trying to implement
providers for different databases such as MySql, SqlServer,
etc...Instead of reinventing the wheel, I would suggest you to go for
Microsoft Enterprise Library (available for both .NET 1.1 & 2.0 from
http://www.microsoft.com/practices ). This library has implentations
for SqlServer and Oracle and you can plug your imlementation for OleDb,
if you have or get from the internet. It's very easy and it reduces
70-80% of your code.

Hope this clears.

Regards,

Hari.

Feb 10 '06 #2
Steve,

Please look at the Enterprise Libraries. I once attempted the same
thing you are and it ended up not working so well. The Enterprise
Libraries will make you happy.

PD

Feb 10 '06 #3
Steve,

Please look at the Enterprise Libraries. I once attempted the same
thing you are and it ended up not working so well. The Enterprise
Libraries will make you happy.

PD

Feb 10 '06 #4
I have no problem with the Enterprise Libraries. They are a time-saver, for
sure. However, without understanding the priniciples involved in designing
them, they are only a temporary convenience.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
<pi****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Steve,

Please look at the Enterprise Libraries. I once attempted the same
thing you are and it ended up not working so well. The Enterprise
Libraries will make you happy.

PD

Feb 10 '06 #5
Hi Steve,
1) Is there a way to share .cs files across several projects? I'm used
to this with C++, but in c# it seems that this results in a copy of the
files into each project. Is there a way to reference a file from another
project? or just a file by itself?
As a C++ programmer, some of this may sound elementary to you, but bear with
me, if you will.

A project is (essentially) a tool for creating an assembly. An assembly can
span multiple DLLs, but usually they do not. A file is a tool for creating a
namespace, a class, or classes, and/or other .Net programming entities. A
solution is a combination of projects, which creates a combination of
assemblies that comprise the various elements of an application, service, or
other solution to a set of requirements.

So, if you want to create a DAL, you don't necessarily want to create 3
different DAL projects. You may only need to create one. In particular, if
you're thinking of sharing a single file between multiple projects, it
sounds for all the world as if you want to create an assembly that can be
used by different solutions. For example, if you are always going to be
working from a single type of data provider, such as the .Net SQL Server
provider, exposed in the System.Data.Sql... namespaces, you will only need
one assembly with one namespace and one set of classes. On the other hand,
if you want your DAL to work with multiple and various data providers, you
may need a more complex structure, using inheritance, and/or a factory
pattern, such as is illustrated in the Microsoft Enterprise Library (see
http://msdn.microsoft.com/library/de...l/EntLib2.asp).
In fact, you can use the Enterprise Library straight out of the box, but I
would recommend studying it, so that you can, as you seem to want to,
improve your own design skills.
2) Typically, do companies use one giant DAL assembly for all
applications needing a DAL?
That depends upon the company, and upon the requirements and anticipated
requirements of the company.
3) From what I understand of things, if I wanted to have 3 DAL assemblies
all inheriting a common "base DAL" class, I would have a total of 4
assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies
for each application?
Not necessarily. See my earlier explanation. A single assembly can contain
multiple namespaces and classes. Whether it does or not is pretty much up to
you, and your requirements.

If you have Visual Studio.Net, take a look at the Object Browser. It will
give you a nice picture of the contents of various assemblies, and you can
get a lot of clues from Microsoft's solution as to how you might like to
structure your own.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
"Steve" <ss*@sss.com> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl... Hi all,

I'm designing my DAL layer(s) for our suite of applications and I'm
designing myself in circles, it's gotten to the point where each idea just
mixes me up more :)

We have 3 loosely related applications and I would like to use an assembly
for the DAL in each of them. I have thought of using a single assembly
for all of them with several different classes for providers/application
specific code, thought of a separate assembly for each application, etc.

I have several questions that I'm hoping will lead to some clarity if I
can get them answered and hopefully you can help with some of the answers.

1) Is there a way to share .cs files across several projects? I'm used
to this with C++, but in c# it seems that this results in a copy of the
files into each project. Is there a way to reference a file from another
project? or just a file by itself?

2) Typically, do companies use one giant DAL assembly for all
applications needing a DAL?

3) From what I understand of things, if I wanted to have 3 DAL assemblies
all inheriting a common "base DAL" class, I would have a total of 4
assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies
for each application?

4) Check out my little inheritance thing below, question will follow:
class DALBase
abstract class DAL_AppCommon : DALBase
class DAL_AppCommonMySql : DAL_AppCommon
class DAL_AppCommonSqlServer : DAL_AppCommon

abstract class DAL_AppInventory : DALBase, DAL_AppCommon
class DAL_AppInventoryMySql : DAL_AppInventory
class DAL_AppInventorySqlServer : DAL_AppInventory

What I'm trying to achieve is to have a concrete instance of say...
DAL_AppInventory and have it inherit the appropriate DAL_AppCommon derived
class. In other words, if I Instantiate DAL_AppInventoryMySql, I would
like it to also have the DAL_AppCommonMySql methods/properties.

I know that I can create a factory for each DAL_App* class and then have a
instance member of DAL_AppCommonMySql in my DAL_AppInventoryMySql, but I
would rather do this with inheritance if possible. I hope that makes
sense.
General pointers/tips/clues VERY welcome.

Thank you for reading,
Steve

Feb 10 '06 #6
Thank you for the suggestion, I have been playing with them here and there
or awhile now, very nice solution!
<pi****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Steve,

Please look at the Enterprise Libraries. I once attempted the same
thing you are and it ended up not working so well. The Enterprise
Libraries will make you happy.

PD

Feb 13 '06 #7
Wow, great email Kevin, thanks for taking the time to cover that.

Much of what you wrote was already known, but it's always helpful to revisit
things and think about them again.

As far as design skills go, I ran across a library over the weekend that is
utilizing many of the patterns I have read about in my various books. It's
called Composite Application Block. It took about 10 hours of looking over
this code and poking at it before I had my "Ohhhh, I get it. Cool!" moment
:)

Anyway, I appreciate your email, it helped me lay things out a little more
in my head.
Have a good one,
Steve
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi Steve,
1) Is there a way to share .cs files across several projects? I'm used
to this with C++, but in c# it seems that this results in a copy of the
files into each project. Is there a way to reference a file from another
project? or just a file by itself?


As a C++ programmer, some of this may sound elementary to you, but bear
with me, if you will.

A project is (essentially) a tool for creating an assembly. An assembly
can span multiple DLLs, but usually they do not. A file is a tool for
creating a namespace, a class, or classes, and/or other .Net programming
entities. A solution is a combination of projects, which creates a
combination of assemblies that comprise the various elements of an
application, service, or other solution to a set of requirements.

So, if you want to create a DAL, you don't necessarily want to create 3
different DAL projects. You may only need to create one. In particular, if
you're thinking of sharing a single file between multiple projects, it
sounds for all the world as if you want to create an assembly that can be
used by different solutions. For example, if you are always going to be
working from a single type of data provider, such as the .Net SQL Server
provider, exposed in the System.Data.Sql... namespaces, you will only need
one assembly with one namespace and one set of classes. On the other hand,
if you want your DAL to work with multiple and various data providers, you
may need a more complex structure, using inheritance, and/or a factory
pattern, such as is illustrated in the Microsoft Enterprise Library (see
http://msdn.microsoft.com/library/de...l/EntLib2.asp).
In fact, you can use the Enterprise Library straight out of the box, but I
would recommend studying it, so that you can, as you seem to want to,
improve your own design skills.
2) Typically, do companies use one giant DAL assembly for all
applications needing a DAL?


That depends upon the company, and upon the requirements and anticipated
requirements of the company.
3) From what I understand of things, if I wanted to have 3 DAL
assemblies all inheriting a common "base DAL" class, I would have a total
of 4 assemblies. Is that correct? 1 base DAL assembly, then 3 more
assemblies for each application?


Not necessarily. See my earlier explanation. A single assembly can contain
multiple namespaces and classes. Whether it does or not is pretty much up
to you, and your requirements.

If you have Visual Studio.Net, take a look at the Object Browser. It will
give you a nice picture of the contents of various assemblies, and you can
get a lot of clues from Microsoft's solution as to how you might like to
structure your own.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
We got a sick zebra a hat,
you ultimate tuna.
"Steve" <ss*@sss.com> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl...
Hi all,

I'm designing my DAL layer(s) for our suite of applications and I'm
designing myself in circles, it's gotten to the point where each idea
just mixes me up more :)

We have 3 loosely related applications and I would like to use an
assembly for the DAL in each of them. I have thought of using a single
assembly for all of them with several different classes for
providers/application specific code, thought of a separate assembly for
each application, etc.

I have several questions that I'm hoping will lead to some clarity if I
can get them answered and hopefully you can help with some of the
answers.

1) Is there a way to share .cs files across several projects? I'm used
to this with C++, but in c# it seems that this results in a copy of the
files into each project. Is there a way to reference a file from another
project? or just a file by itself?

2) Typically, do companies use one giant DAL assembly for all
applications needing a DAL?

3) From what I understand of things, if I wanted to have 3 DAL
assemblies all inheriting a common "base DAL" class, I would have a total
of 4 assemblies. Is that correct? 1 base DAL assembly, then 3 more
assemblies for each application?

4) Check out my little inheritance thing below, question will follow:
class DALBase
abstract class DAL_AppCommon : DALBase
class DAL_AppCommonMySql : DAL_AppCommon
class DAL_AppCommonSqlServer : DAL_AppCommon

abstract class DAL_AppInventory : DALBase, DAL_AppCommon
class DAL_AppInventoryMySql : DAL_AppInventory
class DAL_AppInventorySqlServer : DAL_AppInventory

What I'm trying to achieve is to have a concrete instance of say...
DAL_AppInventory and have it inherit the appropriate DAL_AppCommon
derived class. In other words, if I Instantiate DAL_AppInventoryMySql, I
would like it to also have the DAL_AppCommonMySql methods/properties.

I know that I can create a factory for each DAL_App* class and then have
a instance member of DAL_AppCommonMySql in my DAL_AppInventoryMySql, but
I would rather do this with inheritance if possible. I hope that makes
sense.
General pointers/tips/clues VERY welcome.

Thank you for reading,
Steve


Feb 13 '06 #8

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

Similar topics

1
by: Afaq | last post by:
Hi, After adding large number of empty resource files (which will be updated later), we are not able to compile the project. the following is the output of the build process. It fails while...
0
by: JKJ | last post by:
I'm not an OOP guru, but I would say ". . .not necessarily" What if the base class and derived classes are internal? Then the base class has to be within the same assembly to be inherited from. ...
8
by: Donal McWeeney | last post by:
I have a big Visual Studio class library project from which I create an assembly. This assembly for example might contain 100 public entry points (for example custom server controls) and a load of...
10
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post...
0
by: Edward Diener | last post by:
In Borland's VCL it was possible to divide a component into design time and run time DLLs. The design time DLL would only be necessary when the programmer was setting a component's properties or...
4
by: bill | last post by:
I am migrating a VB6 webclass (IIS application) to a dotNet webforms project. There are dozens of designers, class modules, and code modules in this webclass project, which I will move into...
1
by: keliie | last post by:
I have a relatively simple (I assume) issue which I am at a complete loss to address. My issues is: I want to populate fields in my tables with summary data from the same table. Let me explain: ...
4
by: illegal.prime | last post by:
Hi all, I'm getting unexpected results when trying to preload assemblies into an AppDomain I'm creating. Upon creation of the AppDomain - I attach an AssemblyResolve to both my current AppDomain...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.