# Is this an acceptable MVVM Model with IEditableObject implementation?

I'm trying to follow MVVM pattern in a VB.net WPF application, and I would like to implement IEditableObject.

Is this code acceptable for an MVVM application? In particular is it okay to have the IEditableObject implemented here on the Model rather than the ViewModel?

Public Class Component : Implements IEditableObject
Property Name As String
Property Part_Number As String
Property Position_Count As Integer
Property Stage as Integer
Private _stored_properties As Hashtable = Nothing

Get
Return Name + " " + Stage.ToString()
End Get
End Property

Public Sub BeginEdit() Implements IEditableObject.BeginEdit
Dim properties = Me.GetType.GetProperties
_stored_properties = New Hashtable(properties.Length - 1)
For Each prop In properties
If prop.GetSetMethod IsNot Nothing Then _stored_properties.Add(prop.Name, prop.GetValue(Me, Nothing))
Next
End Sub

Public Sub EndEdit() Implements IEditableObject.EndEdit
_stored_properties = Nothing
End Sub

Public Sub CancelEdit() Implements IEditableObject.CancelEdit
If _stored_properties Is Nothing Then Return
Dim properties = Me.GetType.GetProperties
For Each prop In properties
If prop.GetSetMethod IsNot Nothing Then prop.SetValue(Me, _stored_properties(prop.Name))
Next
End Sub
End Class

• Do you want a code review, or just an answer to your question? If you just want an answer it might be better to ask on Stack Overflow. Oct 21 '19 at 14:18
• @pacmaninbw Sorry quite inexperienced on this part of SE, I take it both isn't an acceptable answer? I can edit it to just be code review if required? Oct 21 '19 at 14:25
• No, now that you've clarified what you are looking for it's fine. Oct 21 '19 at 14:29