Code Style
Pureline
Spec 1.1 47 Regeln 5 Sprachprofile
Code without noise.
Mein eigener Code Style. Linearer Kontrollfluss, klare Absicht, kein unnötiger Code — komplett dokumentiert mit stabilen Regel-IDs und Profilen für Java, JavaScript, TypeScript, Go und Crystal.
Die Spezifikation steht im englischen Original.
Fünf Prinzipien
- Linear Flow
- Explicit Intent
- Minimal Noise
- Small Units
- Clear Ownership
PL-CF-001
Der Unterschied
Dieselbe Logik zweimal. Verschachtelt rutscht der Happy Path immer weiter nach rechts — mit Guard Clauses bleibt er auf der Grundebene.
if (request != null) {
if (request.valid()) {
var session = sessions.create(request.user());
return executor.execute(session, request);
} else {
return Result.invalid();
}
}
return Result.empty(); if (request == null) {
return Result.empty();
}
if (!request.valid()) {
return Result.invalid();
}
var session = sessions.create(request.user());
return executor.execute(session, request); Pureline Core
Die Core-Regeln
Gelten für jede Sprache, soweit die Sprache sie natürlich zulässt.
- PL-CORE-001 Control flow should be as linear as possible
- PL-CORE-002 Avoid
else - PL-CORE-003 Prefer guard clauses
- PL-CORE-004 Use the clearest control-flow form for the language; brace-based languages use explicit blocks
- PL-CORE-005 Idiomatic language-native shorthand is allowed when it remains immediately readable
- PL-CORE-006 Functions should be small and focused
- PL-CORE-007 Names must carry meaning
- PL-CORE-008 Avoid unnecessary abstractions
- PL-CORE-009 Avoid God Classes and God Modules
- PL-CORE-010 Prefer immutable state
- PL-CORE-011 Prefer modern language features where they improve clarity
- PL-CORE-012 Avoid unnecessary vertical formatting
- PL-CORE-013 Comments must not compensate for unclear code
- PL-CORE-014 Handle invalid and error states early
- PL-CORE-015 Keep important side effects visible
- PL-CORE-016 Resources must have a clear lifecycle
- PL-CORE-017 Prefer framework-native APIs
- PL-CORE-018 Avoid magic values
- PL-CORE-019 Make dependencies explicit
- PL-CORE-020 Optimize hot paths deliberately, not accidentally
Kapitel
Die Spezifikation
Jedes Kapitel mit Regeln, Begründung und Codebeispielen — was Pureline ist und was nicht.
Architektur & Praxis
Sprachprofile
Java 10 Regeln
- Package by Responsibility
- Naming
- Prefer Records for Immutable Data
- Braces Are Mandatory
- Use Semicolons
- const First
- Avoid any
- Use Types Deliberately
- No Java-Style I Prefix
- Error Guards
- Avoid else After Terminating Branches
- Naming Must Remain Idiomatic
- Idiomatic Postfix Guards Are Allowed
- Avoid else
- Idiomatic Naming
Tooling
Ein Regelwerk, überall
Checker, Formatter, CLI und IDE-Plugins teilen sich dieselbe Spezifikation. Jede Diagnose verweist auf eine stabile Regel-ID.
- Pureline Checker
- Pureline Formatter
- Pureline CLI
- IntelliJ Plugin
- VS Code Extension
- Eclipse Plugin
- future IDE integrations
PL-CF-002
Avoid else after a terminating branch.
Line 48:
} else {
Suggested fix:
Remove the else block and continue with the happy path. So soll sich Pureline-Code anfühlen
- linear
- explicit
- compact
- modern
- low-noise
- modular
- predictable
- easy to scan
- easy to refactor
- hard to misunderstand
Code without noise.
Pureline standardizes principles, not syntax.