Coding Style Guide

Language-agnostic coding style guide for OSBR repositories. Per-language guides:

How to read this guide

1. Correctness by Construction β€” Zero Runtime Errors 🏠

Every rule below serves one goal: eliminate avoidable runtime errors and make the unavoidable ones explicit.

Rationale: literal zero runtime errors is impossible β€” external systems fail. The target is to make every avoidable error a compile error and every unavoidable one an explicit, handled value. The strict-typing, total-type, and error-handling rules below are the mechanism.

2. Functional Style 🏠

Rationale: stricter than mainstream, which permits classes and limits immutability to the binding level.

3. Design Principles & Separation of Responsibilities

These rules apply the handbook's Clean Architecture, DiP, DI, and Ubiquitous Language commitments. SOLID is stated paradigm-neutrally; Robert C. Martin restates it without reference to classes.

3-1. Single Responsibility 🌎

Rationale: SRP is a cohesion rule, not "do one thing." The function-cohesion reading is the functional community's.

3-2. Separation of Concerns 🌎

Rationale: the term originates with Dijkstra (EWD447, 1974).

3-3. The Dependency Rule 🌎

Rationale: an entity "can be a set of data structures and functions" (Martin), so a pure functional domain is in scope; the layer count is an example, not a mandate.

3-4. Dependency Inversion 🌎 (functional mapping is community practice)

Rationale: the function mapping is Seemann's synthesis, not Martin's wording.

3-5. Ports & Adapters 🌎

Rationale: Hexagonal Architecture (Cockburn); the structural form of Β§5's boundary rule β€” Bernhardt's "functional core, imperative shell."

3-6. Responsibility Segregation 🌎

Rationale: Fowler β€” "for most systems CQRS adds risky complexity"; using it by default is Over Engineering (Β§4).

4. Simplicity First β€” KISS / YAGNI 🌎

5. Error Handling

Rationale: Go 🌎 β€” errors-as-values is mandated by Go. TypeScript & Python 🏠 β€” Google's guides and PEP 8 use exceptions; the Result policy is an OSBR choice.

6. Formatting & Tooling 🌎

References