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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When to use classes?

Status
Not open for further replies.

johnk

MIS
Jun 3, 1999
217
US
I have been reading some opinions that classes are frequently overused. Yet, they seem to me to be the obvious best choice for multi-tier, multi-user architecture. I am not a computer scientist, but classes to me are the key to using PC networks for applications previously requiring minis or even mainframes.<br>
<br>
We quickly found out that transfering data between objects by exposing properties was very inefficient. We also started with clunky ways of passing database data between tiers. But we have overcome these issues by such as wrapping multiple properties in a single variant and doing the same with recordsets.<br>
<br>
What are your experiences with classes? When are other approaches more appropriate?<br>
<br>
JohnK
 
Hi John,<br>
<br>
From what I've read in the past year (my only experience with Client/Server) it seems that you're doing the right thing in passing data in one string variable between components. <br>
<br>
The one -DON'T- that seems to be clear to me is exposing properties between the Data-Centric tier and UI-Centric tier. Every time a property is accessed, control returns to the Data-Centric tier. If you have a class that has 20 properties, you would be making 20 trips across the network to get all of them which is a performance disaster. That's why we save the entire record into a string variable and send it back to the UI-Centric tier, which in turn parses that string into data fields. One shot, In and Out and nobody gets hurt :)<br>
<br>
Exposing properties in the UI-Centric tier to the UI is not a problem as they both reside on the same desktop and in my experience I haven't seen any problems with performance.<br>
<br>
I would also like to hear other opinions.<br>
<br>
Tarek
 
I don't think that classes are the problem, its as you say how to pass data between. If you pass any data to function on a remote component, it must be passed by val if possible. <br>
<br>
Even if you are writing code for a form, its much slower to reference a property that a variable.<br>
<br>
In my opinion people don't spend enough time thinking about traffic on the network, be it communicating with a remote component, or using a server side cursor. When these apps are running on a 10mb network its fine, however when you dial up with the same app the response is rubbish.<br>
<br>
Cal
 
Our experience is consistent with Tarek's & Cal's.<br>
<br>
Some academics teach models without regard to current equipment technology limitations. I can visualize a day when we can create an object for each item in a large inventory. They would &quot;float&quot; in memory for near instantaneous access by the teir in which they were resident. But for now we must be practical in our designs.<br>
<br>
Another factor is making it easy (and safe) for journeyman programmers to arrange for data exchange between tiers. We have not only developed standardized techniques for this, but have built code generators which place this code in each place where needed. They also handle the passing of DB error messages and responses up and down the chain of tiers.<br>
<br>
When tiers are resident on different machines, I know of no practical way in MS platforms to avoid the use of classes.<br>
<br>
In fact, classes have become our friends. It is only the misuse of them that causes concern. I agree that using ByVal parameters is a must. We have had very goos results in using multi-dimentional arrays for passing even recorsets between tiers.<br>
<br>
JohnK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top