Why Library developers don't make all variables Public instead of Private and then make some 'Public' on demand ?

AnandGupta

Expert
Licensed User
Longtime User
Many times I am noticing that a library developer makes a variable 'Public' on demand. I still do not understand the need of making variables Private in first place.
Can some one throw some light on it ?
 

Alexander Stolte

Expert
Licensed User
Longtime User
Because not everything is intended for the end user. Module variables should also not be set to public, but made available with get and set subs (if needed). You then also have the option of restricting the use if it should only be read-only and adding a description. And for some properties you have to write additional code so that changes are visible at all. And many usecases for variables only appear when users use this library.
 

aeric

Expert
Licensed User
Longtime User
I think it also related to OOP.
If too many properties and methods are exposed then it also become a long list in intellisense.
 
Top