Clean Fracanto

Clean Fracanto #4 — KISS

KISS — Simplicity as an Architectural Decision

Simplicity as an Architectural Decision

Keep It Simple, Stupid — the simplest solution that works is the best.

C Instead of C++ as a Deliberate Simplification

The choice of C11 over C++ is itself a KISS decision. C++ offers virtual methods, templates, RAII, and smart pointers — all mechanisms that can make polymorphism and resource management more elegant but also increase the complexity of the build system, error messages, and runtime behavior. In the embedded world, where deterministic execution, minimal footprint, and transparency over memory layout are decisive, C is the simpler choice.

The vtable pattern in fracanto makes explicit what C++ conceals behind language mechanisms: Every function pointer is visible, every void *ctx cast is traceable, every indirection is readable in the code. There is no hidden vtable, no implicit copy constructor, no template instantiation that bloats the binary.

Flat Abstraction Hierarchy

fracanto avoids deep inheritance hierarchies — there is simply no inheritance. The abstractions are flat: one vtable, one instance, one wrapper. There are no abstract base classes inheriting from other abstract base classes. The relationship between interface and implementation is always direct and single-step.

Driver Simplicity Through DI

The Dependency Injection in the drivers is a textbook example of KISS. A driver like the ADS8866 ADC needs three things: spi_transfer for reading, cs_set for chip select, optionally mux_select for the multiplexer. That is all. The driver knows no framework, no CAN protocol, no state machine. It receives its hardware functions during initialization and calls them — nothing more.

This simplicity is not accidental but a consequence of the architecture: Because the layers are cleanly separated (Clean Architecture), because the interfaces are narrow (ISP), because the dependencies are inverted (DIP), each driver can remain simple. Complexity arises not in the individual components but in their interplay — and this interplay is orchestrated by the vtables and the dispatch bridge in module.c.

Testability as a KISS Indicator

An often overlooked aspect of KISS: Simple code is simple to test. The 263 driver tests run on macOS without hardware because the drivers are built so simply that mock functions suffice. No test needs to simulate a complex environment — it injects functions that record calls and return predefined results. When a test becomes complex, that is often a signal that the tested code is too complex. In fracanto, the tests are lean because the drivers are lean.