Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Distributed Applications / May 2006

Tip: Looking for answers? Try searching our database.

project references when building N-tier apps

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Owen Richardson - 08 May 2006 23:05 GMT
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
Robert Wilczynski - 08 May 2006 23:34 GMT
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@something.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,
>
[quoted text clipped - 21 lines]
> Many thanks
> Owen
Owen Richardson - 09 May 2006 08:31 GMT
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!

>Hi Owen,
>
[quoted text clipped - 59 lines]
>> Many thanks
>> Owen

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.