sinpro.dev
Docs
Server
Updating the server
  • Company Information
    • Portfolio
    • About
    • Services
    • Events
  • Dev Environment
    • macOS Settings
    • Chrome Extensions
    • VSCode Workspace Settings
    • VSCode Workspace Extensions
    • Global NPM Packages
    • npm-check-updates
    • SvelteKit
    • Customize Zsh
    • ChatGPT Prompts
    • Tailwind CSS
    • Warp
    • Keyboard Shortcuts
  • Assets
    • Assets
    • JPG/PNG to AVIF
    • TTF to WOFF2
  • Clean Code
    • Clean Code
    • Format
    • Quality
    • Variables
    • Functions
    • Objects and Data Structures
    • Classes
    • Concurrency
    • Error handling
    • Comments
  • Code Style
    • TypeScript Config
    • Prettier
    • ESLint
    • Stylelint
  • Testing
    • Vitest
    • Playwright
  • Git
    • Git Branches and Commits
    • Git Hooks
    • Git User Profiles
    • Git for Windows
  • GitHub
    • GitHub Issues
    • GitHub Pull Requests
    • GitHub Repository Settings
    • GitHub Branch Protection
    • GitHub Actions
  • Code Quality
    • SonarCloud Coverage
  • Server
    • SSH
    • PM2
    • Caddy
    • Updating the server
    • ngrok
  • Team sinProject
    • Our Team Policy
    • Equipment and Supplies
    • Books
    • Slack
    • Locales
    • Funny Apps
    • Docs History
  • Talk
    • Talk
    • Creating a Project
    • App Structure

Clean Code

Comments

Edit this page

Prefer self explanatory code instead of comments

Bad
// Check if subscription is active.
if (subscription.end_date > Date.now) {
	/* ... */
}
Good
const is_subscription_active = subscription.end_date > Date.now

if (is_subscription_active) {
  /* ... */
}

Don’t leave commented out code in your codebase

Bad
do_stuff()
// doOtherStuff()
// doSomeMoreStuff()
// doSoMuchStuff()
Good
do_stuff()

Don’t have journal comments

Bad
/**
 * 2016-12-20: Removed monads, didn't understand them (RM)
 * 2016-10-01: Improved using special monads (JP)
 * 2016-02-03: Removed type-checking (LI)
 * 2015-03-14: Added combine with type-checking (JR)
 */
function combine(a: number, b: number): number {
  return a + b
}
Good
function combine(a: number, b: number): number {
  return a + b
}
Error handling TypeScript Config
© sinProject. v0.73.0
On this page
  • Comments
  • Prefer self explanatory code instead of comments
  • Don’t leave commented out code in your codebase
  • Don’t have journal comments