By the theories of OO we should use the private member within the class but not the Property.
But properties can be used to validate a value before being assigned to the private variable.
My personal idea is, when validation is required, have a separate private method to do validation and call that method inside the property’s setter and else where.
Private m_name As String
Public Property Name() As String
Set(ByVal Value As String)
Dim validValue As Boolean
validValue = ValidateName(Value)
If validValue Then
m_name = Value
Private Function ValidateName(ByVal p_name As String) As Boolean
If p_name.Length < validvalue =" ValidateName(p_name)" m_name =" p_name">
Or should we set the property in side SetName method?
What is the best practice to use in such situations?
Please send in your ideas