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:

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:


Component Design

Components should:

Business logic should remain outside presentational components.


Functions

Functions should:

Prefer small functions over large procedural blocks.


TypeScript

Production code should use TypeScript.

Avoid:

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:

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:

Avoid installing packages for trivial functionality.


Performance

Performance should be considered during development rather than postponed until later.

Developers should:


Security

Developers should:

Security should be considered throughout development rather than during deployment.


Code Reviews

Code submitted for review should be:

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:

The additional development effort is outweighed by improved maintainability over the lifetime of a project.


Best Practices Checklist

Before opening a Pull Request, verify:


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.