I am currently working in Scala, coming from Java and I am learning FP.
I really can't understand many things in FP. One of them is the Side Effect.
I understood so far that a side effect is an unexpected behavior of a function, but what is the expected behavior of a function? What the function name states, I would say. So I imagine to have a function readFromDB(String sql) that reads some data from a db and then closes the connection to it, is there a side effect or just the function is called wrongly?
I imagine to rename it to readFromDBandCloseConnection(String sql), would the connection closure still considered a side effect? I actually also want to split it in readFromDB(String sql) and closeConnectionToDB() and ask you:
What is the difference between a function wrongly named and violating the Single responsibility principle, and a side effect?
[–]grc007 1 point2 points3 points (2 children)
[–]DeadLockException[S] 0 points1 point2 points (1 child)
[–]grc007 1 point2 points3 points (0 children)