Could someone tell me the meaning of \"side effect\" in the following line?
If you\'re calling an EL function that doesn\'t return anything, then you\
A side effect is when a method call changes a class's state. So
public class SideEffectClass{
private int state = 0;
public doSomething(int arg0){
state += arg0;
}
}
Here, doSomething(int arg0) has the side effect of changing the state variable.
When you think of a program, you can think of it as instructions + state + input. So if the domain of a program is the range of all possible input * state, and the program has side effects, you can see that the codomain of possible results for the application can grow explosively, as the number of side effects increase. This makes the possible states for the program large, which leads to complicated testing. The functional programming paradigm is designed to eliminate side effects. By making functions first class citizens and by making all declarations immutable functional programming prevents side effects, which makes functional programming shine in parallel processing, as synchronization issues are reduced.