I know that each class should to do its own job. So i always try process my fields by only in class’s methods.If another class processing on my public fields i feel that there is something wrong but is it always right thing to make define private fields ? Would be bad design or code If i let other classes to change my public fields ?
By the way is there name about this design or term word ?
This is called friend classes.
It is not always a bad design principle, but you really have to ask yourself why you would like to expose a field directly and not through a method. If you have a good reason, then you can expose the field directly. However, in most cases such reason does not exist