Coding Standards
Document: 08-coding-standards.md
Version: 1.0.0
Purpose
This document defines the coding standards followed across all Rundown projects.
Consistent coding standards improve readability, maintainability, collaboration, and long-term project quality. Every developer should write code that is easy to understand, easy to review, and easy to extend.
These standards apply to all production code unless explicitly documented otherwise.
General Principles
Every piece of code should aim to be:
-
Readable
-
Maintainable
-
Predictable
-
Testable
-
Reusable
Code is read far more often than it is written. Prioritize clarity over cleverness.
Simplicity
Prefer the simplest solution that satisfies the requirements.
Avoid unnecessary abstraction, excessive nesting, and premature optimization.
If a solution requires extensive explanation, consider whether a simpler approach exists.
Readability
Write code that communicates intent.
Good code should explain itself through clear structure and meaningful naming rather than excessive comments.
Example:
Good:
const featuredProducts = await getFeaturedProducts();
Avoid:
const data = await getFeaturedProducts();
Single Responsibility
Functions, components, and modules should have one clearly defined responsibility.
Large functions should be divided into smaller, reusable units when appropriate.
Reusability
Before creating new functionality, determine whether an existing implementation can be reused or extended.
Reusable code should be:
-
Independent
-
Configurable
-
Well documented
-
Free of project-specific assumptions
Component Design
Components should:
-
Represent a single UI responsibility.
-
Receive data through props.
-
Avoid unnecessary internal state.
-
Be reusable across projects whenever practical.
Business logic should remain outside presentational components.
Functions
Functions should:
-
Perform one task.
-
Have descriptive names.
-
Return predictable results.
-
Avoid hidden side effects.
Prefer small functions over large procedural blocks.
TypeScript
Production code should use TypeScript.
Avoid:
-
any -
Unused types
-
Duplicate interfaces
Types should be shared where appropriate and kept close to the features they represent.
Error Handling
Applications should fail gracefully.
Handle expected errors explicitly.
Examples include:
-
Missing data
-
API failures
-
Invalid user input
-
Authentication failures
Avoid exposing internal implementation details to end users.
Comments
Comments should explain why, not what.
Avoid comments that simply repeat the code.
Example:
Avoid:
// Increment counter
counter++;
Prefer:
// Retry limit is enforced to prevent repeated API requests.
Where code is self-explanatory, comments are unnecessary.
Dependencies
Every dependency increases maintenance overhead.
Before adding a new package, consider:
-
Can this be implemented with existing tools?
-
Is the dependency actively maintained?
-
Does it significantly improve development?
-
Is it appropriate for long-term production use?
Avoid installing packages for trivial functionality.
Performance
Performance should be considered during development rather than postponed until later.
Developers should:
-
Avoid unnecessary re-renders.
-
Lazy load heavy components where appropriate.
-
Optimize images.
-
Minimize JavaScript sent to the browser.
-
Remove unused dependencies.
Security
Developers should:
-
Validate user input.
-
Protect sensitive data.
-
Never expose secrets.
-
Use environment variables.
-
Follow secure authentication practices.
Security should be considered throughout development rather than during deployment.
Code Reviews
Code submitted for review should be:
-
Functional
-
Readable
-
Tested
-
Documented where necessary
-
Consistent with Rundown standards
Receiving review feedback is part of the engineering process and should be viewed as an opportunity to improve the quality of the codebase.
Engineering Decision
Standard Language
Status: Accepted
Decision
TypeScript is the standard programming language for all production web projects.
Reasoning
TypeScript improves:
-
Reliability
-
Readability
-
Refactoring
-
Tooling
-
Developer experience
The additional development effort is outweighed by improved maintainability over the lifetime of a project.
Best Practices Checklist
Before opening a Pull Request, verify:
-
The code is readable.
-
The solution is as simple as practical.
-
Existing components have been reused where possible.
-
No unnecessary dependencies were introduced.
-
TypeScript types are correctly defined.
-
Errors are handled gracefully.
-
Performance has been considered.
-
Security implications have been reviewed.
Summary
Consistent coding standards enable Rundown to build software that remains maintainable, scalable, and understandable regardless of who wrote the original implementation.
The objective is not to enforce personal preferences but to establish a common engineering standard that benefits every project.
Related Documents
Related ADRs
-
ADR-001: Repository Structure
-
ADR-002: Git Workflow