Primes system Design: Difference between revisions
| (One intermediate revision by the same user not shown) | |||
| Line 11: | Line 11: | ||
<span id="pgcobol-documentation-wiki"></span> |
<span id="pgcobol-documentation-wiki"></span> |
||
= pgcobol — documentation = |
= pgcobol — design documentation = |
||
<blockquote>'''System:''' pgcobol — Three-Tier COBOL / PostgreSQL Prime Numbers Application<br /> |
<blockquote>'''System:''' pgcobol — Three-Tier COBOL / PostgreSQL Prime Numbers Application<br /> |
||
| Line 28: | Line 28: | ||
!width="33%"| What you will find |
!width="33%"| What you will find |
||
|- |
|- |
||
| 🏠| '''[[Primes system Design]]''' |
| 🏠| '''[[Primes system Design]]''' | [[Cobol and PostgreSQL]] |
||
| This page — overview, architecture snapshot, quick-start |
| This page — overview, architecture snapshot, quick-start |
||
|- |
|- |
||
| Line 49: | Line 49: | ||
<span id="system-overview"></span> |
<span id="system-overview"></span> |
||
== System Overview == |
== System Overview == |
||
Latest revision as of 23:28, 24 March 2026
The Primes system was written on top of my head, aimed at creating a consistent three tier object oriented set of Cobol programs using a PostgreSQL backend. It does not serve any purpose, storing prime numbers in a database actually is a bad idea.
Generated Documentation[edit]
Courtesy to claude.ai.
Most of the documentation in this and the underlying chapters, design and specifications have been generated as a result of the reverse engineering of the Cobol program sources. In the process known defects emerged, which is very interesting, so I decided to leave everything 'as is'.
The process was as follows:
- Generate technical specifications from the cobol program sources
- Use the technical specifications to generate a design
- Use the generated design for the creation of a design standard
- Use everything to create a programming standard
pgcobol — design documentation[edit]
System: pgcobol — Three-Tier COBOL / PostgreSQL Prime Numbers Application
Version: 1.0 · Reverse-engineered baseline · 2026-03-17
Runtime: GnuCOBOL 4.0 · GixSQL · PostgreSQL 11 · Linux
[edit]
| Page | What you will find | |
|---|---|---|
| Primes system Design | Cobol and PostgreSQL | This page — overview, architecture snapshot, quick-start | |
| Business Requirements | What the system must do; stakeholders; constraints | |
| ⚙ | Technical Specification | Stack; architecture; pseudocode for all four programs; SQL inventory; file spec; defect register |
| Data Dictionary | Every field in every copybook and working-storage section | |
| Flow Diagrams | Eight Mermaid diagrams — call graphs, sieve loop, report loop, sequence diagrams |
System Overview[edit]
pgcobol is a batch COBOL application that generates prime numbers by trial division, stores them in a PostgreSQL database, and produces a formatted line-printer report. It demonstrates a clean three-tier architecture entirely within COBOL.
┌──────────────────────────────────────────────┐
│ primesmain │ Orchestrator
│ Reads command-line arg → routes to tier │ primesmain.cbl
└───────────────────┬──────────────────────────┘
│ CALL using primes-session
┌───────────▼──────────────┐
│ primesgen │ Business Logic / Sieve Engine
│ Sieve algorithm or │ primesgen.cbl
│ cursor read-loop │
└────────┬─────────────────┘
CALL primes-dal│ │CALL primes-ui
┌───────────▼──┐ ┌──▼──────────────┐
│ primes │ │ primesui │ Presentation
│ DAL + SQL │ │ Print file + │ primesui.cbl
│ primes.cbl │ │ console log │
└──────┬───────┘ └──────────────────┘
│ EXEC SQL via GixSQL
┌──────▼───────────────┐
│ PostgreSQL 11 │
│ schema: primes │
│ table: primes │
└──────────────────────┘
Two Operational Modes[edit]
| Argument | What happens |
|---|---|
generate
|
primesgen runs the sieve from 3 → 999,999,999; each confirmed prime is inserted into the database |
report
|
primesgen opens a cursor over the primes table; each row is written into the formatted print file primes.prt
|
⚠ Known defect: The
generatepath exists in the code but the PERFORM that invokes the sieve loop is commented out inprimesmain.cbl(line 51). See Technical Specification — Defect Register.
Source File Inventory[edit]
| File | Type | Role |
|---|---|---|
primesmain.cbl
|
COBOL program | Entry point — session controller |
primesgen.cbl
|
COBOL program | Business logic — sieve and report loops |
primes.cbl
|
COBOL + GixSQL | Data access layer — all SQL |
primesui.cbl
|
COBOL program | Presentation — print file and console |
primes-session.cpy
|
Copybook | Session-tier control block |
primes-dal.cpy
|
Copybook | DAL-tier control block |
primes-ui.cpy
|
Copybook | UI-tier control block (all programs) |
primes-table.cpy
|
Copybook | SQL host variable — character format |
primes_table.cpy
|
Copybook | SQL host variable — COMP-3 format (duplicate — see Data Dictionary) |
SQLCA.cpy
|
Copybook | GixSQL SQL Communications Area |
primes_schema.sql
|
DDL | Creates schema, sequence, and table |
reset-primes.sql
|
DDL | Drops and recreates schema for a fresh run |
primes_cbsql.out
|
Listing | GixSQL pre-compiler expanded output |
Inter-Tier Communication Pattern[edit]
All programs communicate through method-dispatch control blocks defined in copybooks. The pattern is the same at every tier:
1. Caller MOVEs a verb string into the control block's methods field 2. Caller CALLs the subprogram, passing the control block BY REFERENCE 3. Subprogram EVALUATEs the verb, executes the matching paragraph 4. Subprogram sets a numeric result code before EXIT PROGRAM 5. Caller inspects the result field and branches accordingly
| Tier boundary | Control block | Result codes |
|---|---|---|
| primesmain → primesgen | primes-session
|
0 = ok · 1 = nok · 9 = eof |
| primesgen → primes | primes-dal
|
0 = ok · 1 = nok · 99 = eof |
| any → primesui | primes-ui
|
0 = ok · 1 = nok |
Document Revision[edit]
| Page | Document ID | Last updated |
|---|---|---|
| Business Requirements | PGCBL-BRD-001 | 2026-03-17 |
| Technical Specification | PGCBL-TSD-001 | 2026-03-17 |
| Data Dictionary | PGCBL-DDD-001 | 2026-03-17 |
| Flow Diagrams | PGCBL-FLD-001 | 2026-03-17 |
All pages derived by reverse engineering of source artifacts. Items marked ⚠ indicate known defects or unconfirmed assumptions.
Terug naar: Cobol and PostgreSQL