Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If When data members are declared public or protected, it is difficult to control how they are accessed. Malicious callers can manipulate such members in unintended ways. If Use wrapper accessor methods to expose class members need to be exposed beyond the package in which their class is declared in, wrapper accessor methods may be used. Also, with the . The use of wrapper methods , enables appropriate monitoring and control of the modification of data members can be monitored as appropriate (e.g., by defensive copying, validating input, logging and so on). The wrapper methods must preserve the invariants of the class at all times.

...

This noncompliant code example shows a static, mutable hash map with public accessibility.

...