Write code that prioritizes clarity and simplicity over cleverness. Use appropriate Clojure idioms to make code more readable and maintainable. Key practices:
Write code that prioritizes clarity and simplicity over cleverness. Use appropriate Clojure idioms to make code more readable and maintainable.
Key practices:
str
calls)seq
vs not-empty
)delay
when simpler alternatives existExample of improvement:
;; Instead of complex nested logic:
{:visibility (if (or (not can-open?) (and @*highlight-mode? new?)) "hidden" "visible")}
;; Use descriptive let bindings:
(let [is-new-highlight (and selection @*highlight-mode? new?)
is-existing-highlight (and selection @*highlight-mode? (not new?))
should-display-for-new-highlight (and is-new-highlight (state/sub :pdf/auto-open-ctx-menu?))]
{:visibility (if (or is-existing-highlight should-display-for-new-highlight) "visible" "hidden")})
;; Instead of nested function calls:
(str (string/join ", " (map name (keys (:plugin/installed-plugins @state/state)))))
;; Use thread macros for clarity:
(->> (:plugin/installed-plugins @state/state)
keys
(map name)
(string/join ", "))
This approach makes code more maintainable, especially for team members who may not be familiar with complex Clojure patterns, and reduces cognitive load when reading and debugging code.
Enter the URL of a public GitHub repository