- Problem Space: Where the challenge is defined and candidate solutions are identified. This is the starting point for the algorithm’s intention, understanding what problem must be solved.
- Decision Space: Where rules, constraints, and evaluation criteria are applied to the candidates. Here, every decision is deliberate, ensuring that the algorithm moves toward a correct solution systematically.
- Answer Space: Where the final solution is captured and represented as a concrete result. This is where the algorithm’s goal, the resolution of the problem, is realized.
About The Correct Code Framework
- Understand why a solution works, not just how to code it
- Design systems that are reliable and predictable, rather than ad hoc
- Communicate complex logic precisely across teams, reducing errors and misunderstandings
The Correct Code Framework (CCF) is a reasoning engine that defines how engineers traverse, evaluate, and eliminate candidates within a system.
It is built on the principle of Inversion of Control (IoC), where decision-making responsibilities traditionally delegated to engineers are moved out of the engineering phase and explicitly defined by an architect during the planning phase.
Traditional Computer Science teaches engineers to move from the Problem Space to the Answer Space, but it omits a critical layer, the Decision Space.
CCF introduces the Decision Space as a structured stack of Frames, where all logic, constraints, and execution conditions are defined before runtime.
At its core, the Framework is a detective-style candidate evaluation pipeline that records validated results.
A Frame consists of five layers of evaluation that every Candidate passes through, where logic, constraints, and execution rules are pre-defined. Understanding and properly defining each layer leads to more reliable and efficient solutions.
A Frame does not discover correctness at runtime; it enforces correctness through pre-defined conditions.
The Detective Engine The Framework introduces the Detective Engine, a structured execution model that defines how candidates are traversed, evaluated, and recorded within the Decision Space. It acts as a discovery tool, enabling runtime selection of data structures and traversal strategies at runtime, driven by decisions made as each candidate progresses through the layers of the Decision Space.
- Scanner Role: The Detective Traverses the Problem Space, locates qualified Candidates, and records the results.
- Candidate Role: The Suspect The subject(s) that are being evaluated.
- Invariant Role: The Allegation The rule that must always be true about the Candidate at the time of evaluation.
-
Constraints
Role: The Transport Container
Container shape: The rules that define the data structure that acts as the transport vehicle for qualified Candidates as they move through the Decision Space.
Container capacity: The rules define the capacity of the container, limiting the number of Candidates evaluated per Frame.
The container carries Candidates through the Frame layers, ensuring evaluation rules are applied consistently.
The container capacity influences Space Complexity. Each Frame represents a unit of evaluation; the total number of Frames traversed determines Time Complexity. - Recorder Role: Case File / Record Final Judgment Records the state of qualified Candidates at the time of evaluation.
About The Decision Space The Decision Space consists of the following layers that each valid candidate must pass through.
Intent
Defines the Invariant, what must be proven true about the Candidate being evaluated.
The goal of the Scanner is to navigate the Problem Space, evaluate qualified Candidates, and record the results.
Scope (Container shape)
Defines the structure used to store Candidates as they move through the Decision Space. This determines accessibility, traversal, and containment.
Storage (Container):- Array
- Graph
- Tree
- Stack
- Queue
- Heap / Priority Queue
- Set
- Hash Map / Dictionary
Route
Defines the traversal strategy for moving from one Candidate to the next. Route decisions are based on the data structure selected during Scope evaluation.
Examples:- Linear Scan: sequential traversal.
- Depth-First Search: explore one path fully before backtracking.
- Breadth-First Search: level-by-level exploration.
- Two-pointer: evaluate pairs by converging/diverging pointers.
- Sliding window: maintain a dynamic subset during traversal.
Evaluation
Occurs when Intent, Scope, and Route are aligned. Confirms the Candidate against all defined rules, it does not determine correctness, only validates against pre-defined conditions.
Recorder
Captures the proof of evaluation and stores validated Candidates in the Answer Space. The Recorder is chosen based on the requirements defined by Intent (e.g., Array, Set, Map, or counter).
Core Principle In Correct Code, decisions are not made at runtime, they are constructed as candidates move through the Decision Space. Engineers do not reason about business rules during transcription. They delegate business rules to the Decision Space. Execution enforces the rules and reveals the result. This transforms engineering from runtime decision-making into the construction of decisions that are enforced at runtime.