In VB, Getters and Setters are parts of properties.
Private m_What As Boolean
Public Property What() As Boolean
Get
Return m_What
End Get
Set(ByVal Value As Boolean)
m_What = Value
End Set
End Property
There are two schools of thought on their use. School 1 (which I follow) says: Get/Set form part of the API of a class. The getter/setters are there to help define how a class should be used. They also abstract the public face of a class from it's internal messy details. Sure, for the most part, they're just wrappers for private member variables, but when you need to perform some type checking, permission checking, etc, they provide a good place for that to happen.
School 2 says: Get/Set just take up CPU cycles. This school says that unless you really need a getter/setter, you're better off using a public member variable. Having to enter a getter/setter in order to retrieve a value just wastes time. See
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.