Skip to content

Code Management

Aly Hussein edited this page Jan 9, 2025 · 6 revisions

Code Style and Readability (Naming Convention)

Camel Case

We will use standardized camelCase for identifier names

Guidelines for Camel Case

1. Variables and Function Names

  • Use Camel Case for naming variables and functions.
  • Start with a lowercase letter, and capitalize each subsequent word.
  • Event-handling functions should be prefixed with on, followed by the event they handle.

Examples:

let userName = "John Doe";
function calculateTotalAmount() {
    // function logic
}
function onClick() {
    // handle click event
}

2. Spaces around operators

  • Always put spaces around operators ( = + - * / ), and after commas:

Examples:

let x = x + 1;
const myArray = ["apple", "banana", "pineapple"];

3. Code Indentation

  • Always use tab or 2 spaces for indentation of code blocks (indent using spaces in VSCode, which is default):

Examples:

function onSubmit() {
    //4 spaces
}

Git Related Conventions

Effective Issue Management

To ensure efficient issue tracking and maintain a focused development process, we follow these guidelines:

What constitutes an Issue?

Issues should represent significant items that require discussion, planning, and potentially substantial work. Examples include:

  • User Stories: Descriptions of user needs and desired functionality.
  • Critical Bugs: Errors that severely impact application functionality or user experience.
  • Feature Proposals: Suggestions for new features or major enhancements.

Managing Smaller Tasks

For smaller tasks that contribute to a larger issue, we encourage the use of comments within the relevant issue. This keeps related work organized and avoids cluttering the issue tracker with minor items.

How to List Tasks in Comments:

This table demonstrates how to break down a larger issue into smaller, manageable tasks within a GitHub issue comment.

Status Task Name Description Assigned To
☐ Design Login Form Create the HTML structure and basic styling for the login form. @octocat
⏳ Implement Input Validation Add client-side validation for email and password fields. @defunkt
☑ Connect to Backend API Integrate the login form with the backend API for authentication. @github
🚫 Add Error Handling Implement error handling for invalid credentials and network issues. @octocat
☐ Write Unit Tests Write comprehensive unit tests for the login functionality. @defunkt
☑ Update Documentation Update the project documentation with details about the new login feature. @github

Explanation of Status Symbols:

  • ☐ Not Started
  • ⏳ In Progress
  • ☑ Completed
  • 🚫 Blocked

How to Use This in a GitHub Comment:

Simply copy and paste this Markdown table into a GitHub issue comment. GitHub will automatically render it as a formatted table. You can then edit the checkboxes, task names, descriptions, and assigned contributors directly within the comment.

Branching and Pull Request Strategy

Our project utilizes a simple and consistent branching model:

  • main: This branch represents the production-ready code deployed to the public. It must always be stable, bug-free, and deployable.
  • dev: This branch serves as the integration branch for all new features and changes before release. Workflow:
  1. Create a new feature branch (e.g., feature/new-login) from dev.

    Note: It is highly recommended to prefix branch names with a commit type followed by a forward slash. This helps categorize branches and makes it easier to understand their purpose. Examples: feature/, bugfix/, refactor/, docs/. See below for a list of common commit types.

  2. Develop and commit changes within the feature branch.

  3. Create a Pull Request (PR) targeting the dev branch.

  4. After code review and approval, merge the feature branch into dev.

  5. Delete the feature branch.

  6. When ready for release, merge dev into main.

This workflow ensures a clean and manageable codebase, facilitating continuous integration and deployment.

Commit Message and Changelog Conventions

To maintain a clear and traceable project history, we follow these conventions:

Linking to Issues:

All commits and Pull Requests (PRs) must be linked to a relevant issue using #issue_number (e.g., #123). This automatically connects the commit/PR to the issue on GitHub, providing a clear audit trail.

Commit Message Format:

Use the following format for commit messages:

<type>(<scope(optional)>): <short description>
<longer description (optional)>

Commit Types:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation changes
  • style: Code style changes (formatting, whitespace, etc.)
  • refactor: Code refactoring (no new features or bug fixes)
  • test: Adding or correcting tests
  • chore: Other minor changes (dependencies, etc.)
  • ci: Changes to CI configuration
  • build: Changes to build process/dependencies
  • perf: Performance improvements

Example:

feat(user-authentication): Implement password reset Added password reset functionality via email.

Breaking Changes:

Indicate breaking changes with ! after the type/scope (e.g., feat!: ...) or by adding BREAKING CHANGE: to the commit message footer.

Benefits:

These conventions ensure clear communication, facilitate changelog generation, and improve project maintainability.

IDE

We decided to develop using the industry standard VS-Code environment as it offers great versatility when it comes to extensions, plugins and version control integration.

Directory Structure

Our project directory is organized in 2 main sections each representing the two main services that make up our application. They are split into front-end and back-end. The back-end also includes the database code since it is logical to associate those services together.

Screenshot 2024-11-06 at 10 18 53 PM

For the front-end we utilize the React frameworks directory structure organization which places pages in a folder of their own and also separates page components from everything else as well. This improves modularity as we can simply reference any component on any page we would like. Finally, we have a separate folder for all of our friend-end testing using JEST.

Screenshot 2024-11-06 at 10 19 58 PM

Design Patterns

We are designing a RESTful web application. We plan on employing all the requirements of the RESTful design pattern when it comes to the implementation of our backend API. This will allow us to properly process and handle any incoming and outgoing requests from our servers. The requests will be formatted according to standard conventions (GET, POST, DELETE) with headers and any parameters we require. We will also be implementing RESTful Authentication where we pass the access control to the token bearer in order to authenticate specific requests to resources.

Security Strategy

Currently we are implementing a protected route strategy. We also plan on enforcing security through the use of Auth0 with JSON Web Tokens (JWT). When a user makes a request to a protected route it will pass control to the bearer to authenticate via a token that was assigned when the user securely logged into our system and was confirmed trustworthy.

Logging Infrastructure

For our logging infrastructure we will be using PostHog as it provides detailed insights into user behaviour, is easy to integrate, and offers custom events tracking. It also has great documentation for any custom metrics we wish to track and great visualization tools for those metrics.

Another possible exploration would be using Heap which is a promising user logging tool. Considerations involving pricing and actual utility for our specific use case will be analyzed in the future.

Error Handling

We will use the Sentry platform for the error handling infrastructure of our application. Sentry is a easy to use tool that maximizes efficiency when it comes to logging, analyzing and tracing errors back to the source. Sentry is also a useful tool when it comes to general purpose logging and monitoring the performance of your application. Finally Sentry has extensive documentation on how to integrate their tool within a project seamlessly.

Additional benefits include alerts, tracing errors to the suspect commit that caused them, error analytics, breadcrumbs, session replays and much more.

Performance Considerations

Sentry tracks common application performance metrics such as throughput, latency, page loading time, memory usage and leaks. It also allows you to triage underperforming services by offering analytics and any possible related errors linked to poor performance.