Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

3 Tier VB 6 Solution 1

Status
Not open for further replies.

BlackKnight

Programmer
Oct 18, 2000
348
US
Hi folks,

I am trying to implement a 3-tier solution in VB6. I partially understand the concept of a 3-tier app but I wanted to confirm/correct my assumptions about what each tier, CODE-WISE, is supposed to do and not do. Here is how I understand a 3-tier solution:

1st tier (client)
=================
-A standard EXE project which contains forms or webpages.

-It creates object(s) based upon classes in the 2nd tier DLL to make data requests/saves etc


2nd tier (business logic)
=========================
-An ActiveX DLL

-It has classes to handle data validation, business constraints, and each collection of data objects.

-It manages collections of data objects as in adding, removing, iterating data objects in the collections.

-It handles the data requests from the 1st tier by returning the requested data as an XML document property. (string) which is based upon the collections it manages.


3rd tier (backend)
=========================
-An ActiveX DLL

-It contains objects that represent the data (tables, etc)
with the fields as properties.

-Each data object should be able to connect on its own to the backend so it handles the connection, SQL stored procedures, and db-specific tasks like SPADE.

-Each data object represents ONLY ONE record in a table? (not sure about this one)

-A data object is returned as an XML document property. (string) to the 2nd tier ONLY (meaning not directly to 1st.)

Given my understanding of a 3-tier solution that if a data object represents ONLY ONE record in the 3rd tier, and the 2nd tier is supposed to manage collections of data objects.

my question is:

How do I go about returning more than one record to the 2nd tier without violating the rule that a data object reprsents ONLY ONE record and that the 2nd tier doesn't know about recordsets?

For instance, if I have a customer data object in the 3rd tier and a collection of customers in the 2nd tier. If the 2nd tier requests all customers, in order, to fill out its customers collection, from the 3rd tier how is this done without the 2nd tier knowing about recordsets etc?

Thanx in advance.

Have a good one!
BK
 
In general, when designing 3-tier or n-tier apps using VB's Windows based forms, I start by breaking up the tiers as follows (of course these tiers can be on one computer or a bunch of computers):

1) Presentation layer - Everything that the end user sees goes here. None of the Business Rules or Data Access objects go here.

2.) Middle Tier(s) - I seperate into at least two DLL's. One contains the Data Access functions. The other contains the Business Rules. I try to think in terms of objects when designing these DLL's. Think of the purpose of the object and put all of the related functions in that object. Objects in this tier can work with each other as well as the other tiers.

3.) Back End - This is usually the database. I try to minimize the work done in the back end and let the database do its database function without piling up other stuff in this tier. I mainly use SQL Server so I do end up usuing Stored Procedures here.

I never heard of a hard an fast rule that a data object should represent only one record. Objects for me are just like objects in real life...I might have a connection object that performs the function of establishing a connection to a database for all of my other data objects to use.

For a browser based application, things change a little. Since you're serving pages to the end user, I try and do all of my work outside of the Presentation layer for a whole bunch of reasons.

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top