Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2007, 11:21 AM
Registered User
 
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Project/class/assembly organization

I'm looking for a pattern or standard approach to the following example situation:
(hypothetical)
I want to set up a Class for Employee.
I then want to set up a class called EmployeeDB which handles database activities for an employee.
I have another class with common simple functions set up to do things like create formatted logfiles or send email alerts.

I have been trying to organize the different types of classes into differnet projects.
The problem is it seems to create circular references.

The Db class needs to reference the employee class to be able to return employee types. The employee class needs to be able to refernce the EmployeeDB class so that it can call the database methods.


 Should they just be in the same project to start with?


 Is there a differnet basic approach that would make more sense?





 
Old April 10th, 2007, 02:48 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I use this approach:

Business entity layer project (BOL)
 - references: nothing
 - It will contain the Employee class.

Data access layer project (DAL)
 - references: BOL
 - Here will be a class for Employee data access (EmployeeDA)

Business logic layer project (BLL)
 - references: BOL, DAL
 - Here will be a class for Employee business logic methods. Initially, the methods may seem superfluous because all they really do is call the DAL to delegate responsibility. However, as you expand an application, you'll find that you need to perform more involved business logic on data that goes beyond just getting it from a database. The business layer is where it should go.

You application will need to reference the BLL and BOL, but possibly not the DAL because that's access entirely from the BLL.

Imar (a wrox author and regular poster here) has written a very thorough set of articles about multi-layer application architecture that you might find useful. It uses a very similar approach to what I have described above.

Part 1: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=416
Part 2: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=419
Part 3: http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=420


-Peter
 
Old April 10th, 2007, 02:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote: It uses a very similar approach to what I have described above.
I can confirm it does, as I discussed the concepts in great detail with Peter before I posted the final articles... ;)

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
assembly language project.... help earthdragon12 Assembly Language 0 July 22nd, 2006 07:20 AM
Pls Help ME..Assembly ANd Class allez69 ASP.NET 1.0 and 1.1 Basics 0 June 3rd, 2004 09:45 PM
New project, VB.NET Class Library eirikr BOOK: ASP.NET Website Programming Problem-Design-Solution 0 June 11th, 2003 05:25 PM
Project.Class.Property. ? Jstmehr4u3 VB How-To 4 June 11th, 2003 03:10 PM
Project.Class.Property.? Jstmehr4u3 Pro VB 6 2 June 11th, 2003 11:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.