|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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. |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
||||
|
||||
|
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? |
|
#4
|
|||
|
|||
|
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.
|
|
#5
|
||||
|
||||
|
Quote:
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? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Collection Classes - usage query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|