Results 1 to 5 of 5

Thread: Persistance Property

  1. #1

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141

    Persistance Property

    Can someone explain the persistance property to me? I understand that VB is not a true OO language like Java, however I am confused about: If I create 2 instances of a class in VB will each instance retain it's properties.

    i.e. I have a ball class, the only property is color. I create one instance and set the color to RED and then I create another instance and set the color to BLUE

    dim r as new myDLL.MyClass
    dim b as new myDLL.MyClass

    r.color = "red"
    b.color = "blue"

    'Will This always print red then blue, or is there a chance that it could print blue then red, or blue and blue, or red and red.
    debug.print r.color
    debug.print b.color
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

  2. #2

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141
    ** Cough **

    Anyone??
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

  3. #3
    jim mcnamara
    Guest
    In general persistance is maintained two ways:
    the App key in the REGISTRY via SaveSetting GetSetting VB functions.

    Or thru the use of a Property bag. Property bag is used from inside a class to persist that class. You can save the property information with a key.

    In your case you are not talking about persistence:

    You're talking about an idea that doesn't apply to COM: the idea that instances should or could share property values with each other, like thru the use of Public variables. The answer is red is always red, blue always blue. And NO, in spite of some code people have produced here, sharing data between instances of classes almost always leads to disaster, because a property that is common and modifiable across instances of a class means that at no time can any instance ever depend on the contents of the property. It can literally be anything.

  4. #4

    Thread Starter
    Frenzied Member blindlizard's Avatar
    Join Date
    Feb 2001
    Location
    Austin, TX - United States of America
    Posts
    1,141
    So, what you are saying is that I cannot depend on a property of one instance to not be changed by another instance? Is there any way around this? Because in other OO languages C++/Java each instance of an object is seperate from anyother instance. In Java I can have an Array of like objects and know with certainty that each one will keep its SET properties.
    Last edited by blindlizard; Dec 7th, 2001 at 05:25 PM.
    I drink to make other people more interesting!
    [vbcode]On Error GoTo Bar[/vbcode]
    http://www.monsterlizard.com

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    In your example the instances would each return the value you assigned to them. Yes each instance of an object stores its own values.

    So the debug would look like this:
    red
    blue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width