HighTechTalks DotNet Forums  

project references when building N-tier apps

Dotnet Distributed Applications microsoft.public.dotnet.distributed_apps


Discuss project references when building N-tier apps in the Dotnet Distributed Applications forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Owen Richardson
 
Posts: n/a

Default project references when building N-tier apps - 05-08-2006 , 06:05 PM






Hi,

I am making a first attempt at building a n-tier app and have it
organised with the following projects:

GUI.exe
Business.dll
DataAccess.dll
GenericDA.dll

data access references genericDA, business references the dataaccess,
and GUI references business projects but my problem comes becuase of
the way i want to seperate my classes, which i can best explain using
an example: i have a table called user - which has a username and
email address. my DataAccess.dll has a class called UserCRUD which
reads and writes to the database,the get method of UserCRUD has a
return type of User -this return type i want to define in the Business
layer but i cant figure out how to connect the two layers - how do i
make the dataaccess layer aware of the business layer? i tried adding
a project reference to my business project but it says that is a
circular reference. Can someone tell me what i am doing wrong? is it
possible for me to reference a business layer defined object in my
dataaccess layer? if not is there a better way to approach this?

Many thanks
Owen

Reply With Quote
  #2  
Old   
Robert Wilczynski
 
Posts: n/a

Default Re: project references when building N-tier apps - 05-08-2006 , 06:34 PM






Hi Owen,

There are at least 3 things you could do:

1) Extract business objects (or data objects) such as User into a third assembly
which you then reference from both > Business.dll and DataAccess.dll. In
this scenario they will share the common type. If you want to have "active"
objects

eg.:

User user = new User("username", email (AT) something (DOT) com");
user.Save();

then it's probably a bad solution but if the classes are only for carrying
data then that may be the way to go.

2) Make UserCRUD Get methods return IDataReader and construct the object
in the Business.dll (you can have the object construction logic in another
assembly). Insert methods would then have to take multiple parameters (each
property of your User object eg.: UserCRUD.Insert(string userName, string
email) instead of accepting the actual instance of the User class).

3) Make the User class (Business.dll) inherit from UserData class (DataAccess.dll
or better yet a separate assembly). Data access layer would then return an
instance of UserData (only a data carrying object) class which could be transformed
into a business object (User class). This would allow the business objects
to call the data access layer and provide the above mentioned user.Save()
functionality.

You can also look around for ORM tools, see what kind of code those give
you and use those ideas.

Does that help?

Best regards,
Robert Wilczynski.

Quote:
Hi,

I am making a first attempt at building a n-tier app and have it
organised with the following projects:

GUI.exe
Business.dll
DataAccess.dll
GenericDA.dll
data access references genericDA, business references the dataaccess,
and GUI references business projects but my problem comes becuase of
the way i want to seperate my classes, which i can best explain using
an example: i have a table called user - which has a username and
email address. my DataAccess.dll has a class called UserCRUD which
reads and writes to the database,the get method of UserCRUD has a
return type of User -this return type i want to define in the Business
layer but i cant figure out how to connect the two layers - how do i
make the dataaccess layer aware of the business layer? i tried adding
a project reference to my business project but it says that is a
circular reference. Can someone tell me what i am doing wrong? is it
possible for me to reference a business layer defined object in my
dataaccess layer? if not is there a better way to approach this?

Many thanks
Owen



Reply With Quote
  #3  
Old   
Owen Richardson
 
Posts: n/a

Default Re: project references when building N-tier apps - 05-09-2006 , 03:31 AM



This was great help - thanks! I decided to go with method 3 which
probably requires one more post before i can leave this newsgroup free
of my newbieness!

On Mon, 8 May 2006 22:34:13 +0000 (UTC), Robert Wilczynski
<wilczynski.robert (AT) gmail (DOT) com> wrote:

Quote:
Hi Owen,

There are at least 3 things you could do:

1) Extract business objects (or data objects) such as User into a third assembly
which you then reference from both > Business.dll and DataAccess.dll. In
this scenario they will share the common type. If you want to have "active"
objects

eg.:

User user = new User("username", email (AT) something (DOT) com");
user.Save();

then it's probably a bad solution but if the classes are only for carrying
data then that may be the way to go.

2) Make UserCRUD Get methods return IDataReader and construct the object
in the Business.dll (you can have the object construction logic in another
assembly). Insert methods would then have to take multiple parameters (each
property of your User object eg.: UserCRUD.Insert(string userName, string
email) instead of accepting the actual instance of the User class).

3) Make the User class (Business.dll) inherit from UserData class (DataAccess.dll
or better yet a separate assembly). Data access layer would then return an
instance of UserData (only a data carrying object) class which could be transformed
into a business object (User class). This would allow the business objects
to call the data access layer and provide the above mentioned user.Save()
functionality.

You can also look around for ORM tools, see what kind of code those give
you and use those ideas.

Does that help?

Best regards,
Robert Wilczynski.

Hi,

I am making a first attempt at building a n-tier app and have it
organised with the following projects:

GUI.exe
Business.dll
DataAccess.dll
GenericDA.dll
data access references genericDA, business references the dataaccess,
and GUI references business projects but my problem comes becuase of
the way i want to seperate my classes, which i can best explain using
an example: i have a table called user - which has a username and
email address. my DataAccess.dll has a class called UserCRUD which
reads and writes to the database,the get method of UserCRUD has a
return type of User -this return type i want to define in the Business
layer but i cant figure out how to connect the two layers - how do i
make the dataaccess layer aware of the business layer? i tried adding
a project reference to my business project but it says that is a
circular reference. Can someone tell me what i am doing wrong? is it
possible for me to reference a business layer defined object in my
dataaccess layer? if not is there a better way to approach this?

Many thanks
Owen


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.