p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning C# 2005 Databases (http://p2p.wrox.com/forumdisplay.php?f=283)
-   -   Multi Layered Design (http://p2p.wrox.com/showthread.php?t=71065)

jumbojs October 16th, 2008 12:43 PM

Multi Layered Design
 
Hello,

I am working on a program that takes multiple fields from several databases, about 160 to be more specific, and writes the values to a text file. My question is in designing a multi layered app I have it where each DB in the program gets it's own data class and a corresponding business class. Is this the better approach or should I have one data class that uses a join and one business class that is a class of the result set?


DrPurdum October 19th, 2008 11:29 AM

There's a bazillion ways to do this, but I favor a three-tier design in situations like this.

1. The first tier is the user interface. It contains the code that the end user sees and interacts with.

2. The second tier contains the rules that dictate how you want to interact with the data. For example, if the user interface has a login screen, perhaps each person has a different security access code. That way, one employee might have access to some data, but is denied access to other data. This tier enforces those rules.

3. The third tier contains the code that interacts with the data. The sole purpose of this tier is to service the second tier's request for (or edits to the) data. Even though you are working with multiple DB's or tables, I would put everything that talks with the business rules tier in this tier. This decouples the rules from the data server. The advantage is that you isolate the tiers so each becomes a "black box" to the other tiers. Therefore, if you make changes in the data tier, the rules tier need not even know about it.

(WARNING: Ad to follow)
My C# book designs and implements a simple card game in Chapter 10. The user interface is what the player sees (tier 1). The second tier contains the rules for the game (which includes betting), and the third tier is the data server. In this case, rather than being a DB, the data server tier is a deck of cards, with methods for creating the deck, shuffling it, and dealing out cards, etc. While your problem is not a one-to-one match, it can be modeled as such.

I hope this helps...

Dr. Purdum

Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)


All times are GMT -4. The time now is 09:39 PM.

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