How to decide whether the method will be private, secure, internal or public?

I am developing a class where some methods will not do any harm if they are published as public. But they can be private, as they will be used from only one class in my project.

Publishing these features has the following advantages:

  • Unit Testable without accessories.
  • Flexibility.

Private users have the following advantages:

  • Simplification of public documentation.
  • Some unknown errors are not displayed.

What are the general guidelines in this case?

+5
source share
8 answers

, , Ch. 06 of Code Complete 2 Steve McConnell, . .

, "Persona" , . . , , .

, .

, +1 John sanders.

, CC2.

, Satckoverflow? (.)

+4

.

, InternalsVisibleTo AssemblyInfo.cs, unit test .

+13

, , (, ). API ( ).

+5

, . , .

+4

. , .

+3

, , . .

, . .

+2

! .

+1

, , . , , , . , api, api , , , api.

, . , accessors Visual Studio 2005 2008, api . unit test, - api, , .

, , api . , .. unit test, , api , , .

+1

All Articles