Some database application developers prefer to create a data module before main form by editing the project source file like this
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TDM, DM);
Application.CreateForm(TMainForm, MainForm);
{...}
Application.Run;
end.
The question is - why? What are pros and contras?
The obvious reason would be if the main form needs the Data Module for its setup. For example, if there's something in there that the main form references in its OnCreate, then of course the data module would have to be ready first.
Otherwise, it doesn't really matter.
I agree with Mason's answer because it explains why people may do this. However, I believe this is a bad approach because it hides the dependency in code that is maintained by the IDE. In my opinion, the data module should be removed from the auto create list and it should be created in the main form's OnCreate method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With