# Use Computed Properties for Complex Class Logic ## Rule When class bindings involve multiple conditions or complex logic, extract them into computed properties rather than writing inline expressions in templates. ## Why This Matters - Inline class expressions quickly become unreadable with multiple conditions - Computed properties are cached and only re-evaluate when dependencies change - Logic in computed properties is easier to test and debug - Keeps templates focused on structure, not logic ## Bad Code ```vue ``` ## Good Code ```vue ``` ## Style Bindings Too The same principle applies to style bindings: ```vue ``` ## Combining Static and Dynamic Classes Use array syntax to combine static classes with computed dynamic classes: ```vue ``` ## References - [Class and Style Bindings](https://vuejs.org/guide/essentials/class-and-style.html) - [Computed Properties](https://vuejs.org/guide/essentials/computed.html)