well there is that too in a sense but its just best practice/better design. Say you are working on a large project between you and your developers. What happens if a developer accidently, without realizing, sets a value of a property of a class to something which you do not want, or which can cause severe problems during your execution of your application, such as calculation or changing a bool value to true instead of having it to false (or whatever) you would be wondering out why on earth it happened or why did they do it - having properties gives you more control on what you can get or set from a private variable in that class.
you might have 2 classes, one class which creates a Person object, the other class to just analyze the Person object - you dont want this analyzing class to modify properties/variables of the Person class right you just want them to read the variables/properties, not set them otherwise not only is it defeating the purpose of "analyzing" the object but also the user would be like "uh...I didn't enter this...why did it change "
you may also only want to pass a class (ClassA) into another class(ClassB) but dont want that class (ClassB) to modify any public variables of this class (ClassA). Therefore having a public property can allow you to control how you wish the caller to access your variables in ClassA
|