Principles¶
Browse the canonical engineering catalogue as a human-readable reference. The YAML entries remain the source of truth; these pages are generated views.
Simplicity, Scope, and Code Clarity
Avoid Accidental ComplexityMinimize complexity introduced by implementation choices rather than the problem itself.Explicit Is Better Than ImplicitMake important dependencies, state changes, defaults, and control flow visible.KISSPrefer the simplest design that correctly satisfies verified requirements.Make It Work, Make It Right, Make It FastSequence development through correctness, design quality, and measured optimization.Meaningful NamesUse names that communicate domain meaning, role, and units.No MagicAvoid unexplained values, hidden side effects, and non-obvious conventions.Principle of Least AstonishmentDesign behavior and interfaces to match reasonable user expectations.Self-Documenting CodeExpress intent through structure, names, types, and explicit control flow.Single Level of AbstractionKeep a function or section focused on one primary conceptual level.Small FunctionsPrefer functions that represent one coherent operation and can be understood locally.Worse Is BetterA simpler, sufficiently correct design can achieve wider adoption and evolve more effectively than a theoretically perfect one.YAGNIAvoid implementing capabilities that are not required by current evidence.
Abstraction, Reuse, and Changeability
Avoid Premature GeneralizationDelay general-purpose abstractions until commonality and variation are understood.Common Closure PrincipleGroup elements that change for the same reasons and at the same times.Common Reuse PrincipleGroup reusable elements so consumers do not depend on things they do not use.DRYAvoid duplicating authoritative knowledge, policy, and decisions.Open/Closed PrincipleAllow known variation through stable extension points without repeatedly editing stable policy.Single Source of TruthGive each authoritative fact or policy one canonical owner.
Modularity, Object Design, and Locality
Composition over InheritancePrefer assembling behavior from collaborators over deep implementation inheritance.EncapsulationControl access to state and preserve invariants through a deliberate interface.High Cohesion, Low CouplingKeep related behavior together while minimizing knowledge between modules.Information HidingHide volatile design decisions behind stable boundaries.Interface Segregation PrinciplePrefer focused consumer-oriented contracts over broad interfaces.Law of DemeterLimit knowledge of distant object structure and collaboration chains.Liskov Substitution PrincipleSubtypes must preserve the behavioral contract expected of the base abstraction.Locality of BehaviourPlace behavior near the data, UI, or concept it primarily affects.Package by FeatureOrganize top-level code around capabilities or business features rather than only technical layers.Separation of ConcernsSeparate responsibilities that represent different concerns or change drivers.Single Responsibility PrincipleGive a module one cohesive responsibility or primary reason to change.Tell, Don’t AskAsk behavior-owning objects to perform operations instead of extracting state and deciding externally.
Contracts, Errors, Validation, and Security
Defensive ProgrammingAnticipate invalid input, partial failure, and misuse at relevant boundaries.Design by ContractSpecify preconditions, postconditions, and invariants for operations and types.Fail FastDetect and report invalid conditions close to their source.Make Illegal States UnrepresentableUse types and constructors that prevent invalid combinations where practical.Parse, Don’t ValidateTransform untrusted input into types that represent validated meaning.Postel’s Law / Robustness PrincipleHistorically: be conservative in output and liberal in accepted input; modern use requires caution.Principle of Least PrivilegeGrant only the permissions and capabilities required for the task.
Architecture and Dependency Direction
Acyclic Dependencies PrincipleKeep component dependency graphs free of cycles at meaningful architectural boundaries.Clean Architecture Dependency RuleSource-code dependencies should point toward higher-level policy.Dependency InjectionSupply collaborators from outside a component instead of constructing hidden dependencies internally.Dependency Inversion PrincipleHigh-level policy should not depend directly on volatile low-level details.Inversion of ControlDelegate control of lifecycle or flow to a framework, runtime, or coordinating component.Ports and AdaptersPlace application policy behind explicit ports and implement external interactions through adapters.Stable Dependencies PrincipleDependencies should generally point toward components that change less often.
State, Side Effects, Data, and Distribution
Command Query Responsibility SegregationUse different models or paths for reads and writes when their requirements materially diverge.Command–Query SeparationAn operation should either change state or return information, with exceptions made explicit.Eventual ConsistencyReplicated or derived state may be temporarily inconsistent but converges under defined conditions.IdempotencyRepeated execution of the same operation has the same intended effect as one execution.ImmutabilityPrefer values that do not change after construction where this reduces reasoning and concurrency risk.
Public APIs, Compatibility, and Evolution
Testing and Verification
Arrange–Act–AssertStructure a test around preparation, one primary action, and verification.FIRST TestsTests should be fast, independent, repeatable, self-verifying, and timely.Given–When–ThenDescribe behavior through context, event, and outcome.One Logical Behaviour per TestKeep each test focused on one coherent behavior, allowing multiple related assertions.Red–Green–RefactorCreate a failing test, make it pass minimally, then improve structure while preserving behavior.Test Behaviour, Not ImplementationPrefer assertions on observable contracts over private structure.Test PyramidUse many fast focused tests, fewer integration tests, and a small number of broad end-to-end tests as a starting heuristic.Test-Driven DevelopmentUse tests to drive small design and implementation increments.
Performance and Resource Efficiency
Safe Change and Engineering Systems
Boy Scout RuleLeave the code you touch slightly better than you found it.Brooks’s LawAdding people to a late software project can make it later.Chesterton’s FenceUnderstand why an existing rule or mechanism exists before removing it.Conway’s LawSystem structures tend to reflect communication structures of their organizations.Gall’s LawWorking complex systems generally evolve from working simpler systems.Linus’s LawWith enough qualified review, many defects become easier to identify.Murphy’s LawFailure paths that are possible should be expected over sufficient time and scale.
Umbrella Concepts and Review Vocabulary
No matching principles.