I have an object, VirtualMachine, it has a Reboot() method, PowerOn() methods etc.
These methods need to call an external API which I proxy via a management class’ static methods to do the work against the external API. Is it good practice to call these manager classes from within an instance of a class?
So for example:
private void Reboot()
{
VirtualMachineManager.Reboot(this.Name);
}
Is it ok to use manager classes like this within OOP?
Don’t see any problem with this until
VirtualMachineManagerclass only executes an action and not stores an information in itself. Usually static method is a sign/intent of stateless execution. It may change a state of an object passed like a parameter, but usually didn’t store some persistent information. So for me it’s good.All described here is a subject of discussion and matter of particular case (application domain). Everyone is free to choose an architecture he prefers, I just described general intent that your class consumer gets when see a
staticmethod declaration/execution.Good luck.