practicalli / practicalli/clojure

Pure funcitons and explicit arguments

Open
#162 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

thinking-functional
Dominant language
Makefile
Stars
117
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Including magic data, that is accessed outside of a function, makes that function impure and more prone to refactor or create similar code using different magic data.

(den retrieve-customer-account [customer-id]
 (slurp (str "https://webservice/customers?" customer-id)))

Where did that webservice URL come from? What happens if it changes, how many places have we hard coded this ??

Generalising the function is also a way to make the function pure. This gives a more generally usable function as well as removing side-effects (side-causes)

(den retrieve [data-source unique-id]
 (slurp (str data-source unique-id)))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no file, test, or documentation entry point; first locate where guidance on pure functions and explicit arguments belongs in the repository. Done means the intended guidance and examples are incorporated in a clearly scoped documentation change.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.