scitools.com

← Metric catalog

Subprograms 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.

Subprograms

API ID: CountDeclSubprogram
Languages: Ada, Basic, Fortran, Jovial, Pascal
Targets: Architectures, Files, Functions, Modules, Packages, Project, Subprograms

Number of subprograms.

Counts local procedures, functions, and similar callable routines — the term "subprogram" comes from Ada, Fortran, and Pascal, which use it directly, but the metric also spans Basic and Jovial.

For example:


package Essential_Demo is

   -- Well-structured if/loop only; reduces fully during essential-complexity
   -- graph reduction.
   procedure Simple_Proc (X : in out Integer);

   -- If/elsif using "and then"/"or else"; demonstrates the "Strict" short
   -- circuit counting.
   function Strict_Func (A, B : Boolean; N : Integer) return Integer;

   -- Case statement where one branch returns early and the others fall
   -- through, so the case stays in the reduced graph; demonstrates the
   -- "Modified" case counting.
   function Case_Func (Day : Integer) return Integer;

   -- Combines a loop, short circuit operators, and a case statement with a
   -- mix of early return and fall-through branches; the most complex
   -- subprogram in the package.
   function Mixed_Func (A, B : Boolean; Day : Integer) return Integer;

end Essential_Demo;

Essential_Demo declares 4 subprograms — Simple_Proc, Strict_Func, Case_Func, and Mixed_Func — so CountDeclSubprogram = 4 for this package.

See Functions for the equivalent concept in C, C#, Java, Python, Rust, and Web, which use that term instead.

Targets By Language: Configuration: