Best practice, copy object, using a shadow Object for a undo functionality

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tomas

    Best practice, copy object, using a shadow Object for a undo functionality

    Hi,

    I am a VB.NET newbie that would like to know the best practise when
    working with objects and undo user changes to objects properties.

    Problem
    The system allows the user to change properties of an object; the
    system then does some time consuming calculation and provide a solution
    to the user. If the user found the solution unsatisfactory, he/she
    could either continue making more changes or undo all changes done
    since the previous calculation.

    Idea
    We were thinking of working with two objects, a shadow object that the
    user can go back to and the object that is involved in the calculation.
    Now and then in code copy the object with its properties to the shadow
    object.

    Is this sensible way, does VB.NET have anything to facilitate this, are
    there any good alternatives?

    I appreciate any comments regarding this dilemma,

    Tomas Nordlander

  • rowe_newsgroups

    #2
    Re: Best practice, copy object, using a shadow Object for a undo functionality

    I would track two variable for each property like so:

    Private m_MyProperty as string
    Private m_MyPropertyDef ault as string

    Public Property MyProperty() as String
    Get
    Return m_MyProperty
    End Get
    Set (value as string)
    m_MyProperty = value
    End Set
    End Property

    Then just set the value of m_MyPropertyDef ault to whatever the default
    needs to be. Then after the calculations, if the user continues to make
    changes just save the new Defaults. Or if the user wants to rollback to
    the last defaults call a sub like the following:

    Private Sub Rollback()
    MyProperty = m_MyPropertyDef ualt
    ' Continue to reset any other properties here
    End Sub

    Does that make sense?

    Thanks,

    Seth Rowe


    Tomas wrote:
    Hi,
    >
    I am a VB.NET newbie that would like to know the best practise when
    working with objects and undo user changes to objects properties.
    >
    Problem
    The system allows the user to change properties of an object; the
    system then does some time consuming calculation and provide a solution
    to the user. If the user found the solution unsatisfactory, he/she
    could either continue making more changes or undo all changes done
    since the previous calculation.
    >
    Idea
    We were thinking of working with two objects, a shadow object that the
    user can go back to and the object that is involved in the calculation.
    Now and then in code copy the object with its properties to the shadow
    object.
    >
    Is this sensible way, does VB.NET have anything to facilitate this, are
    there any good alternatives?
    >
    I appreciate any comments regarding this dilemma,
    >
    Tomas Nordlander

    Comment

    • Tomas

      #3
      Re: Best practice, copy object, using a shadow Object for a undo functionality

      Thanks Seth, it make sense.

      Tomas :)

      rowe_newsgroups wrote:
      I would track two variable for each property like so:
      >
      Private m_MyProperty as string
      Private m_MyPropertyDef ault as string
      >
      Public Property MyProperty() as String
      Get
      Return m_MyProperty
      End Get
      Set (value as string)
      m_MyProperty = value
      End Set
      End Property
      >
      Then just set the value of m_MyPropertyDef ault to whatever the default
      needs to be. Then after the calculations, if the user continues to make
      changes just save the new Defaults. Or if the user wants to rollback to
      the last defaults call a sub like the following:
      >
      Private Sub Rollback()
      MyProperty = m_MyPropertyDef ualt
      ' Continue to reset any other properties here
      End Sub
      >
      Does that make sense?
      >
      Thanks,
      >
      Seth Rowe
      >
      >
      Tomas wrote:
      Hi,

      I am a VB.NET newbie that would like to know the best practise when
      working with objects and undo user changes to objects properties.

      Problem
      The system allows the user to change properties of an object; the
      system then does some time consuming calculation and provide a solution
      to the user. If the user found the solution unsatisfactory, he/she
      could either continue making more changes or undo all changes done
      since the previous calculation.

      Idea
      We were thinking of working with two objects, a shadow object that the
      user can go back to and the object that is involved in the calculation.
      Now and then in code copy the object with its properties to the shadow
      object.

      Is this sensible way, does VB.NET have anything to facilitate this, are
      there any good alternatives?

      I appreciate any comments regarding this dilemma,

      Tomas Nordlander

      Comment

      Working...