Functional Programming
Functional Programming
- Wikipedia
- geeksforgeeks
Why Functional Programming?
- Reason :
- A major goal of functional programming is to minimize side effects
- Better understanding.
- Testing and debugging is easier.
/**
* Car constructor.
*
* @param string $color
*/
public function __construct(string $color)
{
$this->color = $color;
}
/**
* @return string
*/
public function getColor(): string
{
return $this->color;
}
}
- This is how functions in math work: Math.cos(x) will, for the same value
of x, always return the same result. Computing it does not change x.
Function as first Class Entity
- there are lot definition is this concept, some of them are
- functions can be passed as arguments
- functions can be returned as value from others function
- functions can be assigned to a variable
- functions can be stored in data structures
Q&A
References
- https://firlana.com/blog/functional-programming/
- https://medium.com/@ifirlana/functional-programming-33
2e504b0c54
- https://en.wikipedia.org/wiki/Functional_programming
- https://lispcast.com/what-are-first-class-functions/
- https://stackblitz.com/edit/angular-http-client-123
-