The design looks good, but adding all ProvisionData
objects to a list as suggested by Paddy is absolutely must if you want to get any sort of benefits out of your abstraction. That applies even if the three external systems are fixed and will never change. Additionally, separating the operation
to be performed from the object that performs it (aka Command pattern) will make transactional support and undo behavior possible.
Consider this example - Since you would require consistency of data across all your systems, there will be some sort of transactions involved is my guess. If there's a createUser()
operation and one system is down, you wouldn't want the user to be created on the other two systems, so the entire operation should fail from your proxy's point of view. It's easier to deal with these operations in a list vs individually checking each item. With a list, in pseudocode:
/*
* systems object represents a list of systems
* execute() and undo() are methods in the systems object
*
* result represents the result of performing an operation on some systems
* successfulSystems represents systems in which the operation was successful
*/
operation = new Operation("createUser", ["param 1", "param 2", ..])
result = systems.execute(operation);
// if operation failed in any of the systems
if(result.FAILURE) {
// then undo the operation on systems where it did succeed
result.successfulSystems.undo(operation);
}
A list basically allows grouping external subsystems as a whole thus adding another level of abstraction for yourself, and operations such as all
and any
start making a lot of sense than individual checks. Separating the operation adds further benefits.