- 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.
- 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 six 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.
- Scanner Role: The Detective Navigates the Problem Space, observes Candidates, and advances them into the Decision Space for evaluation.
- Candidate Role: The Suspect Any element within the Problem Space that may be evaluated against the defined Invariant.
- 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.
- Finalization Role: Case Conclusion Transforms recorded state into a meaningful result. Determines what is returned and how it is presented.
The Problem Space defines the environment in which the algorithm operates. It is the origin of all candidates, the domain where the problem exists, and where the Scanner begins its traversal.
It is not concerned with how a solution is reached, only with what exists to be evaluated.
At its core, the Problem Space answers three critical questions:
- What is the input?
- What are the possible candidates within that input?
- What relationships or structure does the input impose?
The Problem Space establishes the raw input. Every element within it is treated as a Candidate, a potential solution that may or may not satisfy the Invariant defined later in the Decision Space.
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 (Storage Container)
Scope (Recorder) -> The container where candidates live, defined by both its shape and its limits (the maximum number of elements it can contain).
Shape (Data Structure):- 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.
Algorithm:- Linear Scan: sequential traversal.
- Two-pointer: evaluate pairs by converging/diverging pointers.
- Sliding Window: maintain a dynamic subset during traversal.
- Binary Search: divide-and-conquer traversal on sorted data.
- Depth-First Search (DFS): explore one path fully before backtracking.
- Breadth-First Search (BFS): level-by-level exploration.
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).
Transformation (Optional)
Occurs when the return value is not the full Recorder (data container). This layer converts the recorded data into the required return data type.
Transformation may extract, reshape, aggregate, or reinterpret the data stored in the Recorder to match the expected output format.
Finalization
The final step of the algorithm. Returns the result produced by the system.
Finalization determines what is returned and completes execution. This step always occurs, even when no transformation is required.
The recorder captures truth. The answer space delivers it.