Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Delphi do you use include paths or explicity include all required files?

Tags:

delphi

Looking at our codebase some code is included in a project explicitly and is pulled in from the search path. Does anyone have an opinion as to which is best practise and why?

Update:

I thought I would clarify my question. All our paths are relatives, so we can have multiple branches that all refer to code within their branches. So I'm not asking about relative paths, but whether units should be in the .dpr or picked up using the search path, which is why the previously asked questions don't quite answer my needs. Thanks to everyone

like image 370
mmmm Avatar asked May 01 '09 19:05

mmmm


3 Answers

I have a very basic way of determining this... If the code is specific to the project (not used elsewhere) I include it explicitly. All shared code gets pulled from the library path.

best regards, don

like image 56
Don Dickinson Avatar answered Nov 16 '22 05:11

Don Dickinson


I don't think I can count the number of times I've helped someone who discovered that the compiler was finding a duplicate copy of a unit somewhere on their search path where they did not expect to find it. They couldn't understand why they were changing their code in the editor (on a copy of the units not found in the search path) and not seeing any change in the behavior of the application. Explicitly including the unit and not setting a search path means there can only be one copy of the unit found by the compiler.

like image 4
Craig Stuntz Avatar answered Nov 16 '22 05:11

Craig Stuntz


This has been covered here before:

  • In Delphi, should I add shared units to my projects, to a shared package, or neither?
  • What is the best way to share Delphi source files among projects?

My answer to the first question is also my answer to your question.

like image 1
2 revs Avatar answered Nov 16 '22 06:11

2 revs