Challenge 1: Remove Temporal Coupling
Understand how to remove temporal coupling in PHP functional programming by rewriting the PriceCalculator class using immutability. This lesson helps you apply array functions to create pure, side-effect-free methods, ensuring reliable price computations without unwanted state changes.
We'll cover the following...
We'll cover the following...
Problem statement
In the “Temporal Coupling” lesson of this chapter, a PriceCalculator class was discussed to explain the concept. Later in the lesson, we resolved the issue of temporal coupling by immutability and showed how the constructor of the PriceCalculator and computePrice methods could be rewritten.
Now ...