Code Standards

Comprehensive coding standards and guidelines for contributing to the Azu web framework.

Overview

This document outlines the coding standards, conventions, and best practices that all contributors should follow when working on the Azu framework. Consistent code style and patterns ensure maintainability and readability.

Crystal Language Standards

Code Style Guidelines

Indentation and Formatting

# Use 2 spaces for indentation
class ExampleClass
  def example_method
    if condition
      do_something
    else
      do_something_else
    end
  end
end

# Align method parameters for readability
def complex_method(
  param1 : String,
  param2 : Int32,
  param3 : Bool = false
)
  # Method implementation
end

Naming Conventions

Type Annotations

Code Organization

File Structure

Module Organization

Azu Framework Standards

Endpoint Patterns

Request/Response Patterns

Handler Patterns

Documentation Standards

Code Documentation

API Documentation

Testing Standards

Test Structure

Test Utilities

Performance Standards

Memory Management

Resource Management

Security Standards

Input Validation

Authentication and Authorization

Error Handling Standards

Exception Handling

Logging Standards

Code Review Standards

Review Checklist

Review Process

Best Practices

1. Keep It Simple

2. Fail Fast

3. Be Explicit

Next Steps


Following these standards ensures consistent, maintainable, and high-quality code for the Azu framework.

Last updated

Was this helpful?