What's a good place to put pure functions that have connections to a system?
public class Core { System system; } public class System { SubSystem subSystem; // subSystem.Multiply(a, b); } public class SubSystem { public float Multiply(float a, float b) { return a * b; } } In this case, the SubSystem has a strong connection to the System. The functions within the SubSystem are pure/stateless.
The problem: If there is no state, why bother with the instance when a static class could do the same job?
Essentially it's Core.system.subSystem.Multiply(a, b); over SubSystem.Multiply(a, b);
And, sure we can go with static classes. But what happens when you have multiple systems with multiple static subsystems spread around the project? The connection is lost, and it quickly becomes a mess.
The way I see it, there are the following options:
Core.system.subSystem.Multiply(a, b); // instances SubSystem.Multiply(a, b); // static SystemUtils.SubSystem.Multiply(a, b); // with namespace But which one is best? And is there a better way?