In search of an Elegent Design Pattern for this problem

Discussion in 'Java' started by S. Jacobs, Nov 21, 2003.

  1. S. Jacobs

    S. Jacobs Guest

    I'm trying to come up with an elegent design to solve this problem and
    wondered if anyone had any ideas. Here is the problem:

    Object A - parent object

    Object B - child object in a many to one relationship with parent

    Object B inherits all the properties and values from object A

    Object A can change a value to any property and the change should be
    inherited from Object B

    Object B can change any value of the property inherited from Object A.
    The change should NOT be propogated to any siblings or to Object A.

    Example:

    Object A:
    String test = "objectA"

    Object B1:
    the value of test = "objectA"

    Object B2:
    the value of test = "objectA"

    Action: Object B1 changes the value of test to "objectB"

    Result:
    The value of A.test is "objectA"
    The value of B1.test is "objectB"
    The value of B2.test is "objectA"

    Action: Object A changes the value of test to "objectAAA"

    The user can choose whether to propogate the change to the child
    objects. The user chooses Yes, to propogate the objects.

    Results:
    The value of A.test is "objectAAA"
    The value of B1.test is "objectAAA"
    The value of B2.test is "objectAAA"


    I'm looking for an elegent solution other than the obvious one of
    simply creating 3 identicle objects and copying all the data to all
    objects. I'm hoping to find one that is efficient in both object
    creation and data storage.

    Hope this makes sense! Any and all suggestions are welcome
     
    S. Jacobs, Nov 21, 2003
    #1
    1. Advertising

  2. S. Jacobs

    Filip Larsen Guest

    "S. Jacobs" wrote

    > Action: Object B1 changes the value of test to "objectB"
    >
    > Result:
    > The value of A.test is "objectA"
    > The value of B1.test is "objectB"
    > The value of B2.test is "objectA"
    >
    > Action: Object A changes the value of test to "objectAAA"
    >
    > The user can choose whether to propogate the change to the child
    > objects. The user chooses Yes, to propogate the objects.
    >
    > Results:
    > The value of A.test is "objectAAA"
    > The value of B1.test is "objectAAA"
    > The value of B2.test is "objectAAA"
    >
    > I'm looking for an elegent solution other than the obvious one of
    > simply creating 3 identicle objects and copying all the data to all
    > objects. I'm hoping to find one that is efficient in both object
    > creation and data storage.


    Except for the optional propagation part, it sounds close to what a Map
    with parent functionality can do, like javax.swing.ActionMap and others.
    Perhaps you can find some inspiration there.


    Regards,
    --
    Filip Larsen
     
    Filip Larsen, Nov 21, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fyleow
    Replies:
    3
    Views:
    276
    fyleow
    May 6, 2006
  2. sunny
    Replies:
    1
    Views:
    471
    Salt_Peter
    Dec 7, 2006
  3. Pallav singh
    Replies:
    0
    Views:
    375
    Pallav singh
    Jan 22, 2012
  4. Pallav singh
    Replies:
    0
    Views:
    411
    Pallav singh
    Jan 22, 2012
  5. Pallav singh
    Replies:
    1
    Views:
    460
    Peter Remmers
    Jan 22, 2012
Loading...

Share This Page