Software architecture fitness functions are automated, objective tests that verify whether a system's architecture adheres to specified design goals and quality attributes. Originating from evolutionary computing, where fitness functions measure how well solutions meet objectives, architectural fitness functions enable continuous architecture verification by treating architectural characteristics—such as layering rules, dependency constraints, and quality metrics—as executable assertions within your build pipeline. Unlike manual code reviews or documentation that drift over time, fitness functions provide immediate feedback on architectural violations, allowing teams to govern evolutionary architectures where systems change safely and predictably. The key insight: if an architectural characteristic matters, make it testable—whether that's preventing domain logic from depending on infrastructure, enforcing bounded context isolation in DDD, or ensuring performance stays within thresholds.
What This Cheat Sheet Covers
This topic spans 15 focused tables and 83 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Fitness Function Categories
| Category | Example | Description |
|---|---|---|
noClasses().that().resideInAPackage("..domain..").should().dependOnClassesThat().resideInAPackage("..infrastructure..") | • Tests a single architectural characteristic in isolation • focuses on one concern like dependency direction or naming convention | |
Performance test combining response time < 200ms AND throughput > 1000 req/s AND memory < 512MB | • Evaluates multiple characteristics together • assesses how combined concerns interact (e.g., security + performance). | |
Tests run on git commit or pull request via CI/CD pipeline | • Executes in response to specific events like code push, deployment, or scheduled cron • provides feedback at discrete checkpoints | |
Production monitoring of API latency with alerts when p99 exceeds threshold | • Runs persistently in production or staging • monitors live system behavior and alerts on violations in real-time |