CKTIS / C
program architecture — concept C23
Program architecture separates responsibilities into header interfaces, translation-unit implementations, and explicit data-ownership rules. Boundaries should limit dependencies and hide state; global state and cyclic dependencies make testing, initialization, and safe resource release harder.
Version: C23
Syntax
program architectureProgram architecture separates responsibilities into header interfaces, translation-unit implementations, and explicit data-ownership rules. Boundaries should limit dependencies and hide state; global state and cyclic dependencies make testing, initialization, and safe resource release harder.
In practice, separate the public header from the implementation file, expose only required declarations, and pass dependencies through parameters. An opaque structure allows representation changes without rebuilding client code, while create/destroy functions can state ownership clearly.
Check initialization order, cleanup after partial failure, and cycles between modules. static state complicates parallel tests, and returning a pointer into an object can bind the client to that object’s lifetime.
Examples
#include <stdio.h>
static int double_value(int value) { return value * 2; }
int main(void) {
printf("%d\n", double_value(21));
return 0;
}
Result
42
Program architecture separates responsibilities into header interfaces, translation-unit implementations, and explicit data-ownership rules. Boundaries should limit dependencies and hide state; global state and cyclic dependencies make testing, initialization, and safe resource release harder.