Skip to content

calculator.aug diagrams ​

A small tested application

Project overview · Compiled explanation

Class interactions ​

100%
Mermaid source
flowchart TD
    n0["Console"]
    n1["Arithmetic"]
    n2["Calculator"]
    n3["_SilentLogger"]
    n4["Logger"]
    n5["calculator.aug"]
    n1 -->|"depends on"| n0
    n2 -->|"depends on"| n0
    n2 -->|"implements"| n1
    n2 -->|"calls log; depends on _logger"| n4
    n3 -->|"depends on"| n0
    n3 -->|"implements"| n4
    n5 -->|"calls; calls add"| n2

Sequences ​

Call arrows identify checked targets; loop and branch frames determine when they run. Open that target’s module to follow its implementation. Branches describe alternatives; loops describe repeated work. Native calls and interface dispatch stop at their declared contracts. Exit notes end that path; enclosing recovery and cleanup remain visible.

Arithmetic.add ​

It takes left and right as integers. It gets console (Console) from dependency injection.

It returns int. It can call Console.write.

Interface contract; implementation selected at runtime. Explanation.

Calculator constructor ​

Uses the selected logger to describe each addition. It implements Arithmetic.

The _logger dependency is injected as Logger and stored read-only and privately.

Receive fields: injected _logger. Explanation.

Calculator.add ​

Adds left and right, logging the operation.

It takes left and right as integers. It gets console (Console) from dependency injection.

It returns int — Sum of the two integers. It can call Console.write.

100%
Mermaid source
sequenceDiagram
    participant p0 as Calculator.add
    participant p1 as _logger: Logger
    p0->>p1: log(message=”adding integers”) · interface dispatch
    Note over p0: Return left + right; required cleanup runs before exit

load ​

Demonstrates a checked failure instead of a successful result.

It takes fail as a boolean.

Failures can raise FileError (when fail is true).

100%
Mermaid source
sequenceDiagram
    participant p0 as load

    alt fail is true
    p0->>p0: FileError()
    p0-->>p0: FileError result: FileError
    Note over p0: Raise checked failure FileError(); required cleanup runs<br/>before exit
    end
    Note over p0: Return ”loaded”; required cleanup runs before exit
    Note over p0: May leave with checked errors: FileError

_SilentLogger constructor ​

Test adapter: keeps calculator tests independent of console output. It implements Logger. It is private to this file.

Explanation.

_SilentLogger.log ​

It takes message as a string. It gets console (Console) from dependency injection.

It can call Console.write.

Explanation.

Called contracts ​

Last updated:

The world runs on language