Definition

The public API is often mistaken for the public keyword.

In reality, the public API of a class is composed of:

  • the public methods and properties
  • the protected and non-final (for languages which have that notion) methods and properties
  • the private fields “hidden” behind public methods – the prime example here being auto-generated setters

The public API of a component or a subsystem is the joint set of all the public methods of the classes that the component/subsystem is comprised of.

Additionally, some languages some a “visibility” system at the component level, which can further constrain what can be seen as “public API” in the more coarse view of the system.

Problems

Basically, being careful about what is “public API” counts as due diligence for following the neighbouring principle all objects are valid at all times.