feat(directives): harvest 5 GUI/architecture directives from product-guidelines.md + python.md

This commit is contained in:
ed
2026-07-02 22:11:19 -04:00
parent 2d07df594d
commit fa3e5381fe
5 changed files with 72 additions and 0 deletions
@@ -0,0 +1,23 @@
# modular_controller_pattern — v1
**Why this iteration:** Lifted verbatim from `conductor/product-guidelines.md` §"Code Standards & Architecture" (line 40) + `conductor/code_styleguides/python.md` §15 (lines 234-240). This is the baseline encoding — the imperative-bullet style currently in production.
Future variants will test alternative encodings (rationale-first, tabular) against this baseline.
**Source:** `conductor/product-guidelines.md:40 + python.md:234-240`
---
From `conductor/product-guidelines.md` §"Code Standards & Architecture":
- **Modular Controller Pattern:** To prevent "God Object" bloat in core controllers (like `AppController`), all state-independent or utility logic must be moved to module-level functions. Functions requiring class state should accept the instance as an explicit dependency (`def logic(controller: AppController, ...)`). Massive `if/elif` dispatch blocks must be refactored into handler maps (dictionaries) of module-level functions.
---
From `conductor/code_styleguides/python.md` §15:
## 15. Modular Controller Pattern
To prevent "God Object" bloat in core controllers (like `AppController`):
- **Extract Logic:** Move all state-independent or purely utility logic to module-level functions.
- **Dependency Injection:** Module-level functions that require class state should accept the instance as their first argument (e.g., `def my_extracted_logic(controller: AppController, ...)`).
- **Handler Maps:** Replace massive `if/elif` blocks (like those in event dispatchers) with dictionaries mapping keys to module-level handler functions.
- **Inner Class Extraction:** Never define nested classes or functions within methods. Move them to the module level.