Academia has a disconnect with the industry when it comes to coding practices. Most teachers haven’t much industry experience. They don’t know how it is to maintain a 10 year old project using SOLID and clean code principles.
They just teach whatever has already been in the curriculum for decades. They don’t know that whatever they’re teaching is actually harmful in the industry.
What I’m saying is that it’s hiding too much of the control flow.
Compare it with this code:
public double calculateCommision(Sale sale, Contract contract) { double defaultCommision = calculateDefaultCommision(sale); double extraCommision = calculateExtraCommision(sale, contract); return defaultCommision + extraCommision; }
This is about the same number of lines, but it communicates so much more about the control flow. It gives us an idea which data is involved in the calculations, and where we can find the result of all the calculations. We can make assumptions that the functions inside are independent from each other, and that they’re probably not relying on side effects.
This is also against clean code examples, because Uncle Bob seems to be allergic against function arguments and return values.