EDIT:
Maybe I should ask the question in a different way.
in light of ammoQ's comment, I realize that I've done something like suggested which is kind of a fix and it is fine by me.
But I still want to learn for the future, so that if I develop new code for operations similar to this, I can design it correctly from the start.
So, if I got the following characteristics:
The relevant input is composed from data which is connected to
several different business objects
All the input data is validated and cross-checked
Attempts are made in order to insert the data to the DB
All this is just a single operation from Business side prospective, meaning all of the cross checking and validations are just side effects.
I can't think of any other way but some sort of Operator/Coordinator kind of Object which activates the entire procedure, but then I fall into a Functional-Decomposition kind of code. so is there a better way in doing this?
Original Question
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.