Hi all,
I've been using Lazarus IDE now for the past months. My previous PL was vb.net, and even I don't like it, I've used it because its easy and fast to create apps. Now, I have created few utilities(LOBs) database applications using Lazarus for the company where I presently working. I just want to make sure that my code is friendly to others, that is, not like a huge spaghetti code.
(Disclaimer: My knowledge of Objects is pretty vague when applied to Programming(OOP). So my programming method is mostly procedural.)
I did not use an database abstracting method to let my app work with any databases(because I have no knowledge how to do this yet), also because I am a fan of PostgreSQL and since my code is in-house and not to be released in the public domain. I am interested from anyone's expertise if what I am doing with my code is at least acceptable. Also, I just want to make sure that I am separating the GUI from the database layer.
Part of my work is the code snippet below. The code will let me delete a record from the database. I have separated the db queries in a separate unit(dbqueries). Most of my code resembles below.
My question is, can this code be accepted as doing the separation of GUI from the database layer?
Thank you...
BoxStyle := MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON2;
FMT_Message := 'Do you really want to delete: ''%s'' from the record?';
FMT_Message := Format(FMT_Message,[ColorNametbDel]);
Reply := Application.MessageBox(PChar(FMT_Message), pChar(APPLICATION_Title), BoxStyle);
if Reply = IDYES then begin
if dbqueries.DeleteInkRecord('ink_inv',INK_INV_ID_EDIT) Then begin
if menuShowEmptyInk.Checked Then CheckEmptyInk:= true else CheckEmptyInk:= false;
dbqueries.FillColorGrid(InkDataGrid,SQLQuery1,SQLTransaction1,Datasource1,CheckEmptyInk);
FMT_Message := 'Ink: ''%s'' has been deleted from the inventory database.';
FMT_Message := Format(FMT_Message,[ColorNametbDel]);
mMessages.Append(FMT_Message);
MessageDlg(APPLICATION_Title,
FMT_Message, mtInformation,
[mbOK], 0);
end
else
MessageDlg(APPLICATION_Title,
'Ink: ''' + ColorNametbDel + ''' cannot be deleted from the database.', mtError,
[mbOK], 0);
end;