Versions Compared

Key

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

...

Detection of public and protected data members is trivial; heuristic detection of the presence or absence of getter and setter wrapper methods is straightforward. However, simply reporting all detected cases without suppressing those cases covered by the exceptions to this rule would produce many false positives and appears unlikely to be satisfactory. Sound detection and application of the exceptions to this rule appears to be infeasible; heuristic techniques may be useful.

Related Guidelines

C++ Secure Coding Standard

...

"OOP00-CPP. Declare data members private"

<ac:structured-macro ac:name="unmigrated-wiki-markup

...

" ac:schema-version="1" ac:macro-id="3c158065-a4b4-4549-b126-42c157c5d51e"><ac:plain-text-body><![CDATA[

[[SCG

...

2007

...

AA.

...

Bibliography#SCG

...

07]

...

]

...

Guideline

...

3-2:

...

"Define

...

wrapper

...

methods

...

around

...

modifiable

...

internal

...

state"

]]></ac:plain-text-body></ac:structured-macro>

Bibliography

<ac:structured-macro ac:name="unmigrated-wiki-markup

...

" ac:schema-version="1" ac:macro-id="7c05ec6a-28cc-4710-a35d-a263256cf445"><ac:plain-text-body><![CDATA[

[[Bloch

...

2008

...

AA.

...

Bibliography#Bloch

...

08]

...

]

...

Items

...

13:

...

Minimize

...

the

...

accessibility

...

of

...

classes

...

and

...

members;

...

14:

...

In

...

public

...

classes,

...

use

...

accessor

...

methods,

...

not

...

public

...

fields

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c3d86f1d-11da-412e-b6b8-99f1d1a83975"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

[§6.6 "Access Control"

http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.6]

...

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="53aed5d0-82b1-47a0-a1e3-618a962dab85"><ac:plain-text-body><![CDATA[

[[Long

...

2005

...

AA.

...

Bibliography#Long

...

05]

...

]

...

§2.2,

...

Public

...

Fields

]]></ac:plain-text-body></ac:structured-macro>

...

OBJ00-J. Limit extensibility of classes and methods with invariants to trusted subclasses only      04. Object Orientation (OBJ)      OBJ02-J. Never confuse immutability of a reference with that of the referenced object