[DUG] Chick or egg - My SQL Access

Jackson Gomes jfdmg at hotmail.com
Mon Jun 25 14:18:24 NZST 2012



> Rather than have one data module for the entire app I place the MySQL query components on the forms that use 
> the query. This makes the app user-ready sooner and there are no complications with various forms moving the 
> record pointer in a central query/dataset. Also I find each form has a slightly different query requirement anyway, 
> so centralisation is no advantage.
> 
> So the 'egg' is the TMyConnection in the main form and the subsequent 'chickens' are the queries in the rest of the 
> app's forms. As they are necessarily opened after the main for there should not be any sequencing problems.

I think code re-use should be on top when you are coding. If you have several apps that connects to the same database, having a datamodule for the connection, login checks and general DB functions is a big advantage. If you plan to use the same login code on a Web app (web broker, IntraWeb, etc), you wont need to duplicate your code, just add it to your project and re-use it.
Putting your DB connection component in your main form forces you to include your main form unit in the uses clause of all units, even units that are plain classes with no GUI, which I do not see as a good practice (you will have a business rules unit which depends on a GUI form). If you need to use this same unit in another project, you will need to add your main form of other project to your new project or rearrange it.
Also, adding querys to forms should be avoided, in my opinion, as you may need the same dataset in another part of your application and you will again duplicate code.
You may have a bit extra work at the start, but your code is more reliable and maintenance is easier.
Regards
--Jackson 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20120625/72c1232b/attachment.html 


More information about the Delphi mailing list