I'm working on refactoring a program that saves data in a DB. This program has a Graphic Interface.
The programmer who did this program ( the one i'm working for) would like me to make this project consistent with MVP.
One of the constraints of my job is to try not change the original business code so even if the code is "MVPized" it will be easy understandable.
About the Code
We have a function that saves an object in the DB written in the View. Hence, instead of returning errors, it directly show error message.
Those Message sometimes are complete sentences, sometimes they are error codes.
I have ~10 possible different errors in the function : Checking if every field are not empty , with one message for each field, Checking if the values are not already used, Checking if the saving in the database as gone right, checking if an external applciation as gone right with native function to give an error message (different from checking the field for example). Every checking as its own error message with sometime a special native function called to give the error message ..
So, I moved this function into the Model and made this function return Error codes using an enumeration type ( or tried at least) but the consequence is that now I have a lot of different error codes.
Now I almost finished refactoring this function but I don't feel I did the right thing by doing this.
So my question is : Is making a lot of different error codes a good idea ? Or more precisely, is it a good idea to have a lot of different error codes in only one function ?