Re: use of one or multiple .PAS files

[ DelphiLand FAQ ]

Posted by webmaster Guido on March 10, 2004 at 16:58:22:

In Reply to: use of one or multiple .PAS files posted by Richard on March 05, 2004 at 23:41:28:

: [...] does it make sense to use separate .PAS and unit files for each form that functions as a gateway to additional functionality. Or just accept the defaults and dump all forms and code into the initial .PAS file?


In Delphi, each form has its own .pas file. It's impossible anyhow to "dump all forms and code into the initial .PAS file"! In other words, there is no "initial .PAS file", but initially you allways have one .PAS file per form.

For the rest, it's a question of easy maintenance. A few guidelines:

If you have written classes -- i.e., defined new object types -- put them in separate extra units, .PAS files without a form.

If it's a large project, it's advisable to split it up even more, make a clear separation between interface and calculations (code). In particular, put general functions and procedures into one or more separate units.

In short, try to separate "how it looks" from "what it does". If later on you change the interface, you won't have to change the "motor". And revisions to the motor leave the interface units unchanged.

[ DelphiLand: free Delphi source code, tips, tutorials ]