Maintain clean code organization by moving implementation details to appropriate locations, extracting reusable functionality, and keeping related code together. This improves maintainability and prevents bugs from poor encapsulation.
Maintain clean code organization by moving implementation details to appropriate locations, extracting reusable functionality, and keeping related code together. This improves maintainability and prevents bugs from poor encapsulation.
Key practices:
bundle/esbuild.rs
)deno_core
)Example of good organization:
// Instead of inline implementation details
pub async fn bundle() -> Result<(), AnyError> {
// ... lots of esbuild setup code ...
}
// Extract to dedicated module
// bundle/esbuild.rs
pub async fn ensure_esbuild(...) -> Result<PathBuf, AnyError> {
// esbuild-specific logic here
}
// bundle/mod.rs
pub async fn bundle() -> Result<(), AnyError> {
let esbuild_path = esbuild::ensure_esbuild(...).await?;
// ... main bundling logic ...
}
This approach makes code easier to test, maintain, and understand by grouping related functionality and separating concerns.
Enter the URL of a public GitHub repository