Skip to content

Files

Latest commit

 

History

History
29 lines (18 loc) · 661 Bytes

NestedClassesVisibility.md

File metadata and controls

29 lines (18 loc) · 661 Bytes

Pattern: Public nested class

Issue: -

Description

Nested classes are often used to implement functionality local to the class it is nested in. Therefore it should not be public to other parts of the code. Prefer keeping nested classes private.

Example of incorrect code:

internal class NestedClassesVisibility {

    public class NestedPublicClass // should not be public
}

Example of correct code:

internal class NestedClassesVisibility {

    internal class NestedPublicClass
}

Further Reading