Link to home
Start Free TrialLog in
Avatar of Ron Kidd
Ron KiddFlag for Australia

asked on

Public, Private or Friend Methods

Hello

I am starting in VB.Net from VBA.
I am building a 3 Tier Application. (Application, Business Logic DLL and Data Access DLL)

I have got things working with the Class Properties in the Business DLL as set to Public.

I have been reading more and it seems that I should be setting the Properties to Private?

Is this the Correct way to go? - If so How do I Access the Data from the Application?
Do I have a Get Method for every Property in the Class?
And a Corresponding Set Method?

If I do have Get and Set Methods for each Property (50+) does that slow the Application down?
ASKER CERTIFIED SOLUTION
Avatar of Najam Uddin
Najam Uddin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ron Kidd

ASKER

Why is there do much online and in tutorials saying to never set properties to public Or if you do use public then make them read only?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK

I've done some more reading, am I correct in saying.
When you declare a property without a get and set method one is created behind the scenes with it's own field?

So if I need to add some validation latter then all I have to do is create the get and set methods (This should work without any other code changes?)
When you declare a property without a get and set method one is created behind the scenes with it's own field?
Yes.

So if I need to add some validation latter then all I have to do is create the get and set methods (This should work without any other code changes?)
Yes.
Thanks very much