Published Methods is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Published Methods
API ID: CountDeclMethodPublishedLanguages: Pascal
Targets: Architectures, Classes, Project
Number of local published methods.
Object Pascal's published visibility is accessible from anywhere, just like public, but published members also get run-time type information (RTTI) generated for them, which the IDE's Object Inspector and form-streaming system use to discover and persist them at design time. Properties are published most often, but methods — such as event handlers — can be published too.
For example:
unit sample;
interface
type
TShape = class(TPersistent)
strict private
FArea: Double;
procedure CalcArea;
strict protected
procedure Resize;
published
procedure NotifyChanged;
public
property Area: Double read FArea write FArea;
end;
implementation
procedure TShape.CalcArea;
begin
FArea := 0;
end;
procedure TShape.Resize;
begin
end;
procedure TShape.NotifyChanged;
begin
end;
end.
NotifyChanged is declared published, giving CountDeclMethodPublished = 1.
See Public Methods for the plain (non-published) counterpart, and Strict Private Methods/Strict Protected Methods for Object Pascal's other visibility levels.
Targets By Language:- Pascal: Project, Class, Interface
- For projects and architectures, this metric must also be enabled from "Project Configuration/Metrics/Projects and Architectures" with the "Show aggregated class metrics" option. Enabling this option can be time consuming.
- This metric can be disabled from "Project Configuration/Metrics/Object Orientated" with the "Show method and variable count metrics" option.