Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 16th, 2003, 07:49 PM
NicMic's Avatar
NicMic NicMic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Cheltenham, England.
Posts: 94 NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 35 m 32 sec
Reputation Power: 9
Post Collection Classes - usage query

Hi (me again),

I've just started using collection classes and would appreciate some advice:-

Should all file/db updating occur within the Collection Class or in the singular Class?

For instance, I have a class "Letter" and a collection class "Letters" - the initialise for Letters reads the existing data and calls its own "Add" method to build the collection (having set a flag to indicate we are initialising). Within this "Add" method I build the private Collection. If the initialise flag is not set (indicating I've been invoked to create a new record), should I do the db update within Letters (the collection class) or invoke an "Add" method within Letter?

I guess this is a fairly basic question, but all the examples I've seen build a collection from existing data only.

TIA.

Reply With Quote
  #2  
Old August 17th, 2003, 09:20 AM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
i don't think it really matters. i guess the collection class makes sense since it is the one creating the class.
__________________
Programmer's Corner

Reply With Quote
  #3  
Old August 18th, 2003, 02:48 PM
NicMic's Avatar
NicMic NicMic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Cheltenham, England.
Posts: 94 NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 35 m 32 sec
Reputation Power: 9
Thanks for that, nopoints.

A further question: Validation of the individual data elements of a Class occur within the singular class (in the Lets). Given that I will (as you suggest) perform the db update in the collection class, where should I put the final validation (eg. If strX is "A", strY must be "B" or "C" - that sort of thing)?

I suppose the answer is to put that validation into a public Method in the singular class and call it from the collection prior to doing the db update?

Reply With Quote
  #4  
Old August 18th, 2003, 11:21 PM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
you create a new child class. proceed to set the values of that new class. if it is successful then add it to the database. if not the Add fails.

Reply With Quote
  #5  
Old August 19th, 2003, 02:48 PM
NicMic's Avatar
NicMic NicMic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Cheltenham, England.
Posts: 94 NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 35 m 32 sec
Reputation Power: 9
Quote:
Originally posted by nopoints
you create a new child class. proceed to set the values of that new class. if it is successful then add it to the database. if not the Add fails.


I'm thinking of the following (simplified) situation:-

My db table has three fields: strA, strB and strC

The data rules are as follows:-
If strA is "X", then strC must be empty and strB must be valued at "1".
If strA is "Y", then strB must be empty and strC must be valued at "2".
I can't put that validation in the Let's for strA/B/C, (unless I enforce the assigment to strA to be first, but this is a simple example).

Do I put that cross-validation in the Add method of the child class (is that what I'm calling the singular class, by the way?) and report failure back to the collection class?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Collection Classes - usage query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway