AlexJames
Well-known member
- Joined
- Mar 20, 2020
- Messages
- 65
- Programming Experience
- 10+
Hi All
I've been doing a fare amount of C# courses and one concept is causing me a bit of confusion. To follow best practices you must give your classes the lowest protection/access level possible, the class should know as little as possible about the rest of the application. What i'm struggling to understand is, the majority of the work is done in the classes and the only way to access the class from say a users form is to have for example a users class that is set to public, you need public properties as well as public methods in order to access what you need to from your form. How do you maintain strict access/protection levels for your classes if everything has to be public in order for you to access them ?
Many Thanks
AJ.
I've been doing a fare amount of C# courses and one concept is causing me a bit of confusion. To follow best practices you must give your classes the lowest protection/access level possible, the class should know as little as possible about the rest of the application. What i'm struggling to understand is, the majority of the work is done in the classes and the only way to access the class from say a users form is to have for example a users class that is set to public, you need public properties as well as public methods in order to access what you need to from your form. How do you maintain strict access/protection levels for your classes if everything has to be public in order for you to access them ?
Many Thanks
AJ.