This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Coding Standards
TumiPare edited this page Jun 26, 2023
·
2 revisions
- Files and folders are organised based on a feature or module.
- Used consistent naming conventions for files and folders.
- Separated components, services, and models into their respective folders.
- Component names follow the PascalCase convention.
- Component names are suffixed with Page, Component, or Dialog.
- Each feature or functionality has its own module.
- Related components, services, and models are grouped within the same module.
- Modules are defined and configured using the NgModule decorator.
- Components follow the Angular component structure, utilizing decorators such as @Component, @Input, @Output, and @ViewChild.
- Templates, styles, and logic are organized into their respective sections.
- Components adhere to the Single Responsibility Principle (SRP) by focusing on specific tasks.
- Services encapsulate business logic and data manipulation.
- Services are registered either in the root module (AppModule) or feature modules based on their scope.
- Dependency injection is used to inject services into components.
- Consistent indentation and formatting conventions are followed.
- Proper spacing and line breaks are used to enhance code readability.
- Variable and function names are descriptive, conveying their purpose.
- Strict type checking is enabled by setting "strict": true in the tsconfig.json file.
- TypeScript features like interfaces, generics, and type annotations are utilized.
- The any type is avoided unless absolutely necessary.
- Angular's built-in directives and features are used whenever possible.
- Ionic's UI components are leveraged to achieve consistent and responsive design.
- Observables and reactive programming are employed for handling asynchronous operations.
- Error handling mechanisms are implemented to enhance the user experience.
- Angular's error handling mechanisms, such as ErrorHandler or global error interceptors, are utilized.
- Errors and exceptions are logged for debugging purposes.
- Unit tests are written using Jasmine.
- Components, services, and other application logic are tested.
- Karma and Cypresss are also used for testing.
- Organized files and modules based on the application's features or functionality.
- Use a consistent naming convention for files and modules.
- Separate route handlers, models, and utility functions into their respective modules.
- Endpoint routes are defined using attribute macros provided by Rocket, such as
#[get]
,#[post]
,#[put]
,#[delete]
. - Related routes are grouped within the same module.
- Dynamic routes are handled using route parameters and path variables.
- Route handlers are implemented as functions with clear and descriptive names.
- Route handlers follow the single responsibility principle, focusing on specific tasks.
- Request data handling and validation are performed using Rocket's request guards and extractors.
- Data models or request/response objects are defined using Rust structs.
- Traits such as
FromForm
,FromData
,Serialize
, andDeserialize
are implemented for data serialization and deserialization. - External crates like Serde can be used for advanced serialization and deserialization needs.
- Errors are handled and propagated using the
Result
type in route handlers. - Rocket's error handling mechanisms, such as
Result
combinators (?
operator) and the#[catch]
attribute macro, are utilized. - Custom error types are implemented, or existing crates like
anyhow
orthiserror
are used for structured error handling.
- Rocket's middleware feature is employed for cross-cutting concerns, such as logging, authentication, or request/response modification.
- Custom middleware functions are created or existing middleware crates compatible with Rocket are utilized.
- Unit tests are written to cover route handlers and other application logic.
- Rocket's
rocket::local::Client
is used to simulate HTTP requests in tests. - Testing frameworks like
assert
orexpect
macros can be used for assertions.
- Consistent code formatting conventions, including indentation and line length, are followed.
- Code is formatted using tools like Rustfmt to maintain consistency.
- Descriptive variable and function names enhance code readability.
- Documentation comments (///) are included to provide clear explanations of the code.
- Route handlers, important functions, and modules are documented, highlighting their purpose, input, and output.
- Security best practices, such as input validation, authentication, and authorization, are considered.
- User inputs are sanitized to prevent common web vulnerabilities like SQL injection and XSS.