|
|
|
|
|
by spiralpolitik
4469 days ago
|
|
The problem with this is you are forced to violate Occam's Razor by introducing unnecessary classes and methods when you need to return two related but distinct results from an operation. For example a method to calculate the value of an asset portfolio could return the value of the portfolio and the set of assets that are missing prices in a single call rather than having to make two separate ones (and potentially two iterations through a data collection). Cleaner to be able to return a number (or a money class) and a set of assets rather than having to return CalculationResult. As a bonus you also get to dodge the hardest problem in programming, naming things ;) Most of my issues with Java stem from violations of Occam's Razor of this manner. Compare with say Python where introducing classes is much less necessary and ends up with cleaner and clearer designs. |
|