Skip to content

Files

Latest commit

 

History

History
33 lines (25 loc) · 712 Bytes

max-lines.md

File metadata and controls

33 lines (25 loc) · 712 Bytes

Pattern: File exceeds maximum line count

Issue: -

Description

Large files tend to handle too many responsibilities and can be difficult to understand. While there is no objective maximum, most style guides recommend keeping files between 100 and 500 lines to maintain readability and support the single responsibility principle.

Examples

Example of incorrect code:

// A file with 600 lines
class MyClass {
  // ... 550 lines of code ...
}

function helperFunction() {
  // ... 50 more lines ...
}

Example of correct code:

// A file with 200 lines
class MyClass {
  // ... 150 lines of code ...
}

function helperFunction() {
  // ... 50 lines of code ...
}