views:

326

answers:

5

We are just migrating from D7 to D2010 and are having a debate about cleaning up the project paths. We have a number of directories with a large number of Pas files that are included on some project paths, but only a few of the files are actually used by any single project.

One option is to eliminate the project paths completely and only have all used files in the dpr.

The second option is to keep only the needed files in the dpr and have project paths to the directories for the rest of the files.

Is there any argument for one option over the other?

+3  A: 

I would argue in favor of including all files that the project uses in the project itself. This will improve performance of the "Insights" by ensuring that used units are part of the project. In addition, this will enable you to more easily manage your code inside the Project Manager. Having large complicated paths is fragile and can be hard to manage.

Nick Hodges
+1 for pointing out path management issues. Having worked on configuration management for a large multi-project build that used library paths for any unit not specifically created for each project I can vouch for the headaches this can cause. Especially when a developer forgets to use relative paths. I lost count of the number of times a "quick rebuild" stretched into an hour of tracking down locations of unit files and replacing paths in the project file.
codeelegance
+7  A: 

Having all your units explicitly in the dpr immensely improves compilation time, code completion, error insight and general navigation.
It does not prevent you from keeping your files organized in folders and sub-folders, but just don't rely on the different paths to find them.
On a big project with millions LOC, it makes a huge difference.

François
But where is the limit to add a file reference to the DPR ? I mean you don't add standard VCL like Classes and Dialogs. What about third party components or own components? My project is huge and I still want fast codeinsight.
Roland Bengtsson
As a rule of thumb, I add in the dpr all the units that are not part of the VCL/installed 3rd party components. Those come with the Library path. Everything else is explictely added so that you don't really need the search path. Of course, YMMV, especially if you componentize everything and the rest... :)
François
Can you give some figures about the compilation time effect? Which was the maximum compilation time for an 'unoptimized' project?
mjustin
I don't really remember the 'worse' numbers we had, specially because we try to avoid being in that situation. Our 3MLOC application normally compiles in ~1mn20. Whenever we see that time degrading, we look for added (or implicitly added) units that would be missing from the dpr. I believe we had some jumps to ~3mn a couple of time.
François
+1  A: 

The comments about speeding up Insights got me intrigued and I will give that a try but so far I never included shared units in the projects that used them. Instead I created packages for each library and added them to the project group (mostly for organizational purposes only, i.e. I never actually compile them as runtime packages). I found this easier to manage (especially with all the recent improvements in the project manager) than having all files in one project as the folder hierarchies inside the individual (package-)projects won't be as deep and especially there's no ".."-level that way.

Oliver Giesen
A: 

Reasons to not include all files in the project:

  • less time to open/close a project (forms and datamodules need extra time)
  • faster file refactorings (renaming/moving of files and directories does not require to edit all projects)
  • easier to find the units which are the core requirements and the entry point location for the application logic (uses MyInterfaces, MyTypes, MymMainUnit;)

And this QC entry:

Report No: 77687 (RAID: 273031)
Status: Open Editing in the .dpr source gets slower with more units in the project http://qc.embarcadero.com/wc/qcmain.aspx?d=77687

Update: Now I know that there are many ways to open the project file :) - But my point is that in a dpr with 500 unit references, it is hard to find the 'important' (or 'main') units, which are the starting point to drill down into the source - and it is easier to investigate code if it is a 'lightweight' project file which contains only the necessary unit references.

mjustin
Finding the main unit is always easy: `Alt-p-q` in a German Delphi. :-)
Ulrich Gerhardt
@Ulrich: sorry I can't find it (English version), but I guess this is only meant to find the main form?
mjustin
In my D2007 it's the fifth item of the Project menu. Should be called something like "View Source" in English. And it shows the *.dpr.
Ulrich Gerhardt
@Ulrich see my edit, it does not have to be a VCL application - less units in the uses clause give more clarity
mjustin
Alt-p-v in an English Delphi will take you to the .dpr.
Frank Shearar
@Frank see my update
mjustin
+7  A: 

I'm in favor of separating "library units" from "project units" and keeping all "library units" in the search path, with all the "project units" in the project file. Here's why:

  • Our line-of-business projects are large, almost million-LOC type of projects, but besides those there are literally hundreds of smaller projects for all sorts of tiny little things. Having the "library units" available on the search path makes it really easy to just use those units without adding them to the project: One less step that adds up!
  • Using the search path makes moving PAS files around easier. This matters allot to me since I'm in the process of re-organizing our whole "build environment" to make better use of version control systems.
  • When you change one of the shared units and it becomes dependent on yet an other shared unit, you don't need to updates lots of projects, they just work.
  • I'd never consider adding third-party components (or VCL components) to my project, so why add my "library units" to the project? We need to draw the line somewhere, because if we'd add absolutely all files to the project hoping for faster compile times we'd end up with unmanageably large projects!
  • Delphi automatically changes the name of the files in it's DPR file to be relative file names. Because of this you can't really move your project from it's current position. Now try "branching" and keeping two copies of the project alive at the same time, on the same machine (a "release" and a "work-in-progress"). (this is me tring preparing my build enviroment for GIT, with the sole purpose of being able to BRANCH).

For reference, my "library units" are those units that are used in unrelated projects (think: components and utilities).

Cosmin Prund