I have joined writing middle-size multi-purpose database application as co-lead. It currently has about 150 tables (and growing) and overall functionality you can imagine as very small ERP.
At many places in code, functionalities which would normally belong into procedures (I mean functions without return value) like DeleteAttachment
or SaveRecord
are put into functions with return value reporting their exit status in string. They return either "OK"
on success or messages like "Deletion failed because ......."
or "Insufficient privileges for ......."
.
At the end, often the end user is presented with message they provided. On one hand, this is effective mechanism of tracing of potential problems. On the other hand, I'm not sure whether I should encourage this approach of writing the inner business logic.
I understand that putting non-fatal problems into exceptions is also not very good way to go (EInsufficientUserPrivileges
, ERecordAlreadyExists
). Should we stick with current approach or is there some other which is more suitable for applications using a many checks and business logic?