2 odpowiedzi
+ 4
Functional programming is basically converting each step of an algorithm or task into a mathematical function (more or less).
Functions that doesn't effect other pieces of value or code and doesn't have internal state are called pure functions. Using this type of functions help to write more secure and readable code.
Think of making a cup of tea. At each step of making it you call a function with some parameters and the function returns you a value that you use to continue and perform the next step.
1. GetWater(.5liter);
2. HeatWater(100deg);
3. So on..
Functional programming is a bit cumbersome but it's gaining some popularity with the help of Elixir.
+ 1
if you use in your code functions like:
def blabla():
do something
return something
then its functional programming
if you use Classes, objects, and methods (which is cool if you get familiar with them)
then this is OOP