Skip to content

Latest commit

 

History

History
88 lines (62 loc) · 3.19 KB

STYLEGUIDE.md

File metadata and controls

88 lines (62 loc) · 3.19 KB

Women Techmakers Bamenda Community Backend Coding Style Guide

Welcome to the Women Techmakers Bamenda (WTM Bamenda) community's backend coding style guide. This document outlines the coding conventions and best practices to follow when contributing to our backend projects. Consistency in coding style helps maintain code readability and makes collaboration smoother.

Table of Contents

General Guidelines

  • Write clean, readable, and maintainable code.
  • Keep your code DRY (Don't Repeat Yourself) by reusing code when applicable.
  • Use meaningful variable and function names.
  • Avoid commented-out code in the repository; use version control for historical code.

JavaScript

  • Follow ESLint rules for JavaScript code quality.

  • Use semicolons at the end of statements.

  • Use single quotes for strings unless interpolating variables.

  • Use const for variables that do not need reassignment, let for variables that do.

  • Use arrow functions for concise anonymous functions.

    // Good
    const age = 30;
    const name = 'Alice';
    
    // Avoid
    var x = 10;

Node.js and Express.js

  • Adhere to the Node.js Best Practices guidelines.

  • Organize your code into separate modules and follow the CommonJS module pattern.

  • Use Express.js for RESTful APIs and follow RESTful conventions for routes and HTTP methods.

     // Example of a RESTful route
    app.get('/api/users', (req, res) => {
    // ...
    });

Database

  • Use an ORM (Object-Relational Mapping) or a database library to interact with the database.
  • Document the database schema and update it as needed.

API Design

  • Follow API design best practices, including versioning, proper HTTP status codes, and clear documentation.
  • Document your APIs using tools like Swagger or API Blueprint.
  • Include information on request and response payloads, authentication, and endpoints.

Testing

  • Write unit tests using a testing framework like Jest.
  • Aim for a high test coverage to ensure code reliability.

Naming Conventions

  • Use descriptive and meaningful names for variables, functions, and files.
  • Follow naming conventions like camelCase or snake_case consistently.

Version Control

  • Use Git for version control.
  • Create feature branches for each new feature or bug fix.
  • Write meaningful commit messages that summarize the changes.

Dependencies

  • Document and keep track of project dependencies in a package.json file.
  • Regularly update dependencies to benefit from security patches and new features.

Additional Resources