Strict Protected 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.
Strict Protected Methods
API ID: CountDeclMethodStrictProtectedLanguages: Pascal
Targets: Architectures, Classes, Project
Number of local strict protected methods.
Object Pascal's strict protected is narrower than plain protected: a plain protected member is visible to descendant classes as well as to any code in the same unit (file), while a strict protected member is visible only to the declaring class and its descendants, not to unrelated code elsewhere in the unit.
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.
Resize is declared strict protected, giving CountDeclMethodStrictProtected = 1.
See Protected Methods for the plain (non-strict) access level, Strict Private Methods for the other strict access level, and Published Methods for Object Pascal's public-with-RTTI level.
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.