Summary

Functional programming is an old concept that is gaining popularity, because it's easier to use when trying to increase performance by executing tasks in parallel. In this chapter some concepts from the functional world were presented along with some of the test tools that AssertJ provides. 

Testing functions without side effects is very easy because the test scope is reduced. Instead of testing changes that the function might cause on different objects, the only thing that needs to be verified is the outcome of the invocation. No side-effects means that the outcome of the function is the same as long as the parameters are the same. Therefore, the execution is repeatable as many times as needed and leads to the same result on every execution. Additionally, tests are easier to read and comprehend.

To conclude, Java includes a good API for functional programming if you need to use this paradigm within your projects. But there are some languages, some of them purely functional, that offer more powerful features with better syntax and less boilerplate. You should evaluate whether using one of those other languages might make sense if your project or approach can be purely functional.

All of the examples presented in this chapter can be found at https://bitbucket.org/alexgarcia/tdd-java-funcprog.git.

Now it is time to take a look at legacy code and how to adapt it and make it more TDD friendly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.65.65