I've been using Delphi for years and years and each of my projects is compiled from source into the exe - no packages etc. If 'MyUnitA.pas' is used anywhere, it is simply declared in the interface or implementation section of another unit that requires it. This all works fine everywhere and means that in my project source (dpr) there are only frame definitions (which seem to be needed there else they dont show up in the frame list) and the 'odd' definition of a unit that must be called very early eg madExcept, FastMM etc.
I notice that XE baulks a bit sometimes at resolving stuff in the dpr until you actually compile it. In addition, when working with packages its a warning if stuff has to be implicitly pulled in without having been explicitly added to the package. This got me wondering whether we should be diligently adding ALL of our used units to our dpr (like the package definition) or right-click project and 'Add to project'. What do you do?
I personally have my search path blank and include all units in my .dpr files. The main advantages of this as I see it:
I don't really see any significant disadvantages to this approach. Yes you have to add files to the .dpr file when you include a new 3rd party component, but in my experience that doesn't happen all that often for it to be a big burden.
(Test made on Delphi Xe3 Enterprise)
1 000 000 lines project, 1000 classes, 300 units
I am with David on this one. We/I do exactly the same.
Dependency control is the main benefit. Explicitness in unit use has big advantages. I am never in doubt where the source for a project is coming from.
Another benefit is that we as a team we are never dependent upon search paths in the IDE. All our machines have empty search paths, only items in the debug search path if we are working on getting a control to do our bidding. We only add controls to our IDE when working on the GUI (which is a large in itself, but actually a small part of our software and we use mainly controls that ship with Delphi). And I often de-install them afterwards. Big advantage: when I need to work on a very old version, I can simply pull it from Perforce and build it with the right Delphi compiler. Everything else is taken care of in the dproj (or dof as we can still compile the versions that were based on D5).
Not relying on search paths in the IDE also means our build server doesn't need to be configured with any search paths. We have a utility that keeps the dproj's in line with the configured third party library versions for a version of our software. And we have a utility that creates a cfg file from the dproj/dof. This way, we can build each and every version of our software that is still in use anywhere in the world, regardless of the compiler and third party component versions it needs. And we can do it without changing a single thing in the build server's setup. In fact we build all "active" releases every night if a change was committed to its Perforce branch and don't even think about it.
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