Clean Code JavaScript – Object & Class Patterns Table of Contents Encapsulation Immutability Cohesion Encapsulation // ❌ Bad user . name = 'John' ; // ✅ Good user . rename ( 'John' ) ; Immutability // ❌ Bad user . age ++ ; // ✅ Good const updatedUser = user . withAge ( user . age + 1 ) ; Cohesion // ❌ Bad class User { calculateTax ( ) { } } // ✅ Good class TaxCalculator { calculate ( user ) { } }
clean-codejs-objects
安装
npx skills add https://github.com/damianwrooby/javascript-clean-code-skills --skill clean-codejs-objects