These guidelines ensure consistency, quality, and maintainability across all projects. They provide foundational principles that apply regardless of specific architecture patterns or methodologies.
-
Clarity is Paramount:
- Write code that clearly communicates intent.
- Favor understandable code over clever tricks or excessive brevity.
- Use descriptive, consistent naming following language conventions.
-
Consistent Formatting:
- Maintain uniform indentation, spacing, and line width.
- Leverage automated tools (linters, formatters) to enforce consistency.
-
Purposeful Comments:
- Write comments explaining the "why" behind complex logic or business rules.
- Avoid redundant comments that merely restate the code.
- Document architectural decisions and non-obvious constraints.
-
Function Design:
- Create small, focused functions with single responsibilities.
- Keep functions concise with clear inputs and outputs.
-
Modularity:
- Encapsulate complexity behind clean interfaces.
- Decouple components to minimize dependencies.
- Follow DRY (Don't Repeat Yourself) principles judiciously.
-
Testability:
- Design for testability from the start.
- Separate pure logic from side effects.
- Make dependencies explicit and injectable.
-
Robust Error Management:
- Fail fast with clear error messages.
- Handle edge cases deliberately, not as afterthoughts.
- Validate inputs comprehensively.
-
Security Mindfulness:
- Sanitize user inputs and validate data from external sources.
- Consider security implications in all data handling.
-
Efficient Resource Usage:
- Manage resources (memory, connections, files) properly throughout their lifecycle.
- Choose appropriate data structures and algorithms for the problem.
-
Balanced Optimization:
- Prioritize correct, maintainable solutions first.
- Optimize based on measured performance needs, not assumptions.
- Document performance-critical sections.