Update src/roadmaps/software-design-architecture/content/100-clean-code-principles/105-pure-functions.md

content/software-design-and-architecture
Kamran Ahmed 2 years ago committed by GitHub
parent 9b9ffe8bfa
commit 9ce2301127
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/roadmaps/software-design-architecture/content/100-clean-code-principles/105-pure-functions.md

@ -2,9 +2,9 @@
A pure function is a specific type of function that meets the following criteria:
1. It takes some input, known as arguments, and returns a value or output.
2. It does not cause any observable side effects, such as modifying the state of the system or interacting with external resources.
3. Given the same input, it will always return the same output.
4. It does not depend on any state or variables that are outside of its scope.
- It takes some input, known as arguments, and returns a value or output.
- It does not cause any observable side effects, such as modifying the state of the system or interacting with external resources.
- Given the same input, it will always return the same output.
- It does not depend on any state or variables that are outside of its scope.
Pure functions are considered to be more predictable and easier to test, as their behavior is determined solely by the input they receive and their internal logic. They also make it easier to reason about the behavior of a program, since the output of a pure function is not affected by any external factors. Pure functions are often used in functional programming, where they are considered a key principle. They are also useful in concurrent and parallel programming, as they are less prone to race conditions and other concurrency-related issues.
Loading…
Cancel
Save