Skip to main content

Command Palette

Search for a command to run...

Unit of Code

Updated
1 min read
Unit of Code

Description:

Instructions executed from a process' entry point until its ending with a verifiable result through one or multiple exit points.

Composition:

class Calculator {
  private currentResult: number = 0;

  // Entry point for the unit of code *add*
  public add(summand: number): number {
    /**
     * Beginning of the unit of code's body
     */

    // Exit point
    this.currentResult += summand;

    // Another exit point
    return this.currentResult;

    /**
     * End of the unit of code's body
     */
  }
}

Examples:

  • A function
  • An object method
  • A module feature

🇨🇴 Versión en Español