时间:2022-07-09 18:56:46

Implementing classes so that they adhere to the principle of encapsulation is quite simple. To achieve this goal, there are just two basic rules:

  1. Don't use any public properties.

  2. Don't reference objects outside the class unless the reference was passed to the class as a parameter.