Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here's some rule I'm using to keep my code maintainable (to me):

- Line should not be too long (120 max)

- Function should fit into 1 page in the view port of screen, even when your console and debugger take 1/3 bottom part of the screen.

- Variable name should be pronounceable and longer than 3 letters (to prevent name like `i`, `x`, `s`)

- File should not be too long (1000 lines max).

- Return/Exit/Throw as early as possible.

- Comment:

    - If an `if` take more than 2 condition, it's worth commenting.

    - If a funciton is longer than 10 lines, it's worth commenting.

    - All file's worth commenting.

    - If you ask yourself "should I add comment", add comment.



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: