Is this kind of design - a class for Operations On Object - correct?
- by Mithir
In our system we have many complex operations which involve many validations and DB activities.
One of the main Business functionality could have been designed better.
In short, there were no separation of layers, and the code would only work from the scenario in which it was first designed at, and now there were more scenarios (like requests from an API or from other devices)
So I had to redesign.
I found myself moving all the DB code to objects which acts like Business to DB objects, and I've put all the business logic in an Operator kind of a class, which I've implemented like this:
First, I created an object which will hold all the information needed for the operation let's call it InformationObject.
Then I created an OperatorObject which will take the InformationObject as a parameter and act on it.
The OperatorObject should activate different objects and validate or check for existence or any scenario in which the business logic is compromised and then make the operation according to the information on the InformationObject.
So my question is - Is this kind of implementation correct?
PS, this Operator only works on a single Business-wise Operation.