When referencing class properties from a function within the class do you use the value from the actual property or the private variable value?
Which way is best? Why?
public class
private m_Foo as double
public property Foo() as double
get
return m_Foo
end get
set(byval value as double)
m_Foo = value
end set
end property
public function bar() as double
Dim x as double = 5 * m_Foo
Dim y as double = 3 * Foo
end function
end class
Personally, I try to use the get/set accessor whenever possible, to avoid surprising myself when I change their logic and suddenly places where I access the private field don’t work as expected.