scitools.com

← Metric catalog

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 IDCountDeclMethodPublished
TargetsArchitectures Classes Project
LanguagesPascal
CategoriesMethod Counts Object Oriented
CostQuery

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: